Support hashed aggregation with grouping sets. This extends the Aggregate node with two new features: HashAggregate can now run multiple hashtables concurrently, and a new strategy MixedAggregate populates hashtables while doing sorted grouping.
The planner will now attempt to save as many sorts as possible when planning grouping sets queries, while not exceeding work_mem for the estimated combined sizes of all hashtables used. No SQL-level changes are required. There should be no user-visible impact other than the new EXPLAIN output and possible changes to result ordering when ORDER BY was not used (which affected a few regression tests). The enable_hashagg option is respected. Author: Andrew Gierth Reviewers: Mark Dilger, Andres Freund Discussion: https://postgr.es/m/87vatszyhj....@news-spur.riddles.org.uk Branch ------ master Details ------- http://git.postgresql.org/pg/commitdiff/b5635948ab165b6070e7d05d111f966e07570d81 Modified Files -------------- contrib/postgres_fdw/expected/postgres_fdw.out | 61 +- src/backend/commands/explain.c | 25 +- src/backend/executor/nodeAgg.c | 861 +++++++++++++++++-------- src/backend/lib/Makefile | 4 +- src/backend/lib/knapsack.c | 114 ++++ src/backend/nodes/bitmapset.c | 30 + src/backend/nodes/outfuncs.c | 34 +- src/backend/optimizer/path/costsize.c | 7 +- src/backend/optimizer/plan/createplan.c | 83 +-- src/backend/optimizer/plan/planner.c | 861 ++++++++++++++++++++----- src/backend/optimizer/util/pathnode.c | 150 +++-- src/include/lib/knapsack.h | 17 + src/include/nodes/bitmapset.h | 6 + src/include/nodes/execnodes.h | 21 +- src/include/nodes/nodes.h | 5 +- src/include/nodes/plannodes.h | 2 +- src/include/nodes/relation.h | 30 +- src/include/optimizer/pathnode.h | 4 +- src/test/regress/expected/groupingsets.out | 616 +++++++++++++++++- src/test/regress/expected/tsrf.out | 50 +- src/test/regress/sql/groupingsets.sql | 155 ++++- src/test/regress/sql/tsrf.sql | 2 + 22 files changed, 2544 insertions(+), 594 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers