pdb.agg allows for
these results to be returned in a single “faceted” query. This can significantly improve read throughput, since issuing a single
query uses less CPU and disk I/O.
For example, this query returns the top 3 search results alongside the total number of results found.
Expected Response
Faceted queries require that
pdb.agg be used as a window function:
pdb.agg() OVER () (or pdb.combine_agg(pdb.agg(...)) OVER () in GROUP BY
queries).Facets with GROUP BY
In a GROUP BY query, a bare pdb.agg(...) computes an aggregation per group. To compute a single facet across all matching rows alongside grouped results, wrap pdb.agg(...) in pdb.combine_agg(...) OVER (). Standard OVER () window aggregates (COUNT, SUM, AVG, MIN, MAX) over group columns or group aggregates are pushed down alongside it: