pdb.agg function accepts an Elasticsearch-compatible JSON aggregate query string. It executes the aggregate using the
columnar portion of the ParadeDB index, which can significantly accelerate performance compared to vanilla Postgres.
For example, the following query counts the total number of results for a search query.
Expected Response
Expected Response
Multiple Aggregations
To compute multiple aggregations at once, simply include multiplepdb.agg functions in the target list:
Expected Response
Performance Optimization
On every query, ParadeDB runs checks to ensure that deleted or updated-away rows are not factored into the result set. If your table is not frequently updated or you can tolerate an approximate result, the performance of aggregate queries can be improved by disabling these visibility checks. To do so, set the second argument ofpdb.agg to false.
If a single query contains multiple
pdb.agg calls, all of them must use the same visibility setting (either all true or all false).JSON Fields
Ifmetadata is a JSON field with key color, use metadata.color as the field name:
If a text or JSON field is used inside
pdb.agg, it must use the literal or
literal normalized tokenizer.