In order for ParadeDB to push down an aggregate, a ParadeDB text search operator must be present in the query.
-- Not pushed downSELECT COUNT(id) FROM mock_itemsWHERE rating = 5;-- Pushed downSELECT COUNT(id) FROM mock_itemsWHERE rating = 5AND id @@@ pdb.all();
import { and, count, eq } from "drizzle-orm";import { search } from "@paradedb/drizzle-paradedb";// Not pushed down — no ParadeDB operatorawait db .select({ count: count(mockItems.id) }) .from(mockItems) .where(eq(mockItems.rating, 5));// Pushed down — ParadeDB operator triggers aggregate pushdownawait db .select({ count: count(mockItems.id) }) .from(mockItems) .where(and(eq(mockItems.rating, 5), search.all(mockItems.id)));
from paradedb import All, ParadeDB# Not pushed down — no ParadeDB operatorMockItem.objects.filter(rating=5).count()# Pushed down — ParadeDB operator triggers aggregate pushdownMockItem.objects.filter(rating=5, id=ParadeDB(All())).count()
# Not pushed down — no ParadeDB operatorMockItem.where(rating: 5).count# Pushed down — ParadeDB operator triggers aggregate pushdownMockItem.search(:id).match_all.where(rating: 5).count
// Not pushed down - no ParadeDB operatorawait dbContext .MockItems.Where(item => item.Rating == 5) .CountAsync();// Pushed down - ParadeDB operator triggers aggregate pushdownawait dbContext .MockItems.Where(item => item.Rating == 5 && EF.Functions.All(item.Id)) .CountAsync();
If your query does not contain a ParadeDB operator, a way to “force” aggregate pushdown is to append the all query to the query’s
WHERE clause.
Aggregate pushdown works across joins as well as single tables. When every participating table has a BM25 index and the custom aggregate scan is enabled, ParadeDB computes the result directly from the index’s columnar storage, without scanning the underlying table rows.
NUMERIC columns do not support aggregate pushdown. Queries with aggregates on NUMERIC columns will automatically fall back to PostgreSQL for aggregation.For numeric data that requires aggregate pushdown, use FLOAT or DOUBLE PRECISION instead:
-- Aggregates can be pushed downCREATE TABLE products ( id SERIAL PRIMARY KEY, price DOUBLE PRECISION);-- Aggregates fall back to PostgreSQLCREATE TABLE products ( id SERIAL PRIMARY KEY, price NUMERIC(10,2));
Filter pushdown (equality and range queries) is fully supported for all
NUMERIC columns. Only aggregate pushdown is not supported.