]> granicus.if.org Git - postgresql/commit
Support hashed aggregation with grouping sets.
authorAndrew Gierth <rhodiumtoad@postgresql.org>
Mon, 27 Mar 2017 03:20:54 +0000 (04:20 +0100)
committerAndrew Gierth <rhodiumtoad@postgresql.org>
Mon, 27 Mar 2017 03:20:54 +0000 (04:20 +0100)
commitb5635948ab165b6070e7d05d111f966e07570d81
tree9e8581fa3530ea777b14ce4900ba7cea106e3450
parentf0a6046bcb15c2fe48384ef547df2bfb5d7f0a89
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.fsf@news-spur.riddles.org.uk
22 files changed:
contrib/postgres_fdw/expected/postgres_fdw.out
src/backend/commands/explain.c
src/backend/executor/nodeAgg.c
src/backend/lib/Makefile
src/backend/lib/knapsack.c [new file with mode: 0644]
src/backend/nodes/bitmapset.c
src/backend/nodes/outfuncs.c
src/backend/optimizer/path/costsize.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/plan/planner.c
src/backend/optimizer/util/pathnode.c
src/include/lib/knapsack.h [new file with mode: 0644]
src/include/nodes/bitmapset.h
src/include/nodes/execnodes.h
src/include/nodes/nodes.h
src/include/nodes/plannodes.h
src/include/nodes/relation.h
src/include/optimizer/pathnode.h
src/test/regress/expected/groupingsets.out
src/test/regress/expected/tsrf.out
src/test/regress/sql/groupingsets.sql
src/test/regress/sql/tsrf.sql