Support multi-stage aggregation

Enterprise / PostgreSQL - Robert Haas [postgresql.org] - 20 January 2016 12:46 UTC

Aggregate nodes now have two new modes: a "partial" mode where they output the unfinalized transition state, and a "finalize" mode where they accept unfinalized transition states rather than individual
values as input.

These new modes are not used anywhere yet, but they will be necessary for parallel aggregation. The infrastructure also figures to be useful for cases where we want to aggregate local data and remote data via the FDW interface, and want to bring back partial aggregates from the remote side that can then be combined with locally generated partial aggregates to produce the final value. It may also be useful even when neither FDWs nor parallelism are in play, as explained in the comments in nodeAgg.c.

David Rowley and Simon Riggs, reviewed by KaiGai Kohei, Heikki Linnakangas, Haribabu Kommi, and me.

a7de3dc Support multi-stage aggregation.
doc/src/sgml/ref/create_aggregate.sgml | 16 +-
src/backend/catalog/pg_aggregate.c | 38 ++-
src/backend/commands/aggregatecmds.c | 4 +
src/backend/commands/explain.c | 46 ++--
src/backend/executor/nodeAgg.c | 333 ++++++++++++++++++++----
src/backend/nodes/copyfuncs.c | 2 +
src/backend/nodes/outfuncs.c | 3 +
src/backend/nodes/readfuncs.c | 2 +
src/backend/optimizer/plan/createplan.c | 9 +-
src/backend/optimizer/plan/planner.c | 8 +
src/backend/optimizer/prep/prepunion.c | 2 +
src/backend/parser/parse_agg.c | 36 +++
src/bin/pg_dump/pg_dump.c | 30 ++-
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_aggregate.h | 306 +++++++++++-----------
src/include/nodes/execnodes.h | 2 +
src/include/nodes/plannodes.h | 2 +
src/include/optimizer/planmain.h | 5 +-
src/include/parser/parse_agg.h | 5 +
src/test/regress/expected/create_aggregate.out | 18 ++
src/test/regress/sql/create_aggregate.sql | 17 ++
21 files changed, 652 insertions(+), 234 deletions(-)

Upstream: git.postgresql.org


  • Share