diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-01-20 13:46:50 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-01-20 13:46:50 -0500 |
commit | a7de3dc5c346e07e0439275982569996e645b3c2 (patch) | |
tree | 9d47c8729c497aeff82b196ddf5f85f478c2a21d /src/backend/commands/explain.c | |
parent | c8642d909fdd57c36dd71e0b0bb4071523324794 (diff) | |
download | postgresql-a7de3dc5c346e07e0439275982569996e645b3c2.tar.gz postgresql-a7de3dc5c346e07e0439275982569996e645b3c2.zip |
Support multi-stage aggregation.
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.
Diffstat (limited to 'src/backend/commands/explain.c')
-rw-r--r-- | src/backend/commands/explain.c | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 9827c39e09d..25d8ca075d4 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -909,24 +909,36 @@ ExplainNode(PlanState *planstate, List *ancestors, break; case T_Agg: sname = "Aggregate"; - switch (((Agg *) plan)->aggstrategy) { - case AGG_PLAIN: - pname = "Aggregate"; - strategy = "Plain"; - break; - case AGG_SORTED: - pname = "GroupAggregate"; - strategy = "Sorted"; - break; - case AGG_HASHED: - pname = "HashAggregate"; - strategy = "Hashed"; - break; - default: - pname = "Aggregate ???"; - strategy = "???"; - break; + Agg *agg = (Agg *) plan; + + if (agg->finalizeAggs == false) + operation = "Partial"; + else if (agg->combineStates == true) + operation = "Finalize"; + + switch (agg->aggstrategy) + { + case AGG_PLAIN: + pname = "Aggregate"; + strategy = "Plain"; + break; + case AGG_SORTED: + pname = "GroupAggregate"; + strategy = "Sorted"; + break; + case AGG_HASHED: + pname = "HashAggregate"; + strategy = "Hashed"; + break; + default: + pname = "Aggregate ???"; + strategy = "???"; + break; + } + + if (operation != NULL) + pname = psprintf("%s %s", operation, pname); } break; case T_WindowAgg: |