diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-03-21 09:20:53 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-03-21 09:30:18 -0400 |
commit | e06a38965b3bcdaa881e7e06892d4d8ab6c2c980 (patch) | |
tree | 7fe176a2301090c3bec08999ff77b8d0ab90fabe /src/backend/optimizer/util/pathnode.c | |
parent | 7fa0064092e135415a558dc3c4d7393d14ab6d8e (diff) | |
download | postgresql-e06a38965b3bcdaa881e7e06892d4d8ab6c2c980.tar.gz postgresql-e06a38965b3bcdaa881e7e06892d4d8ab6c2c980.zip |
Support parallel aggregation.
Parallel workers can now partially aggregate the data and pass the
transition values back to the leader, which can combine the partial
results to produce the final answer.
David Rowley, based on earlier work by Haribabu Kommi. Reviewed by
Álvaro Herrera, Tomas Vondra, Amit Kapila, James Sewell, and me.
Diffstat (limited to 'src/backend/optimizer/util/pathnode.c')
-rw-r--r-- | src/backend/optimizer/util/pathnode.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index 541f7790ab0..16b34fcf46a 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -1645,10 +1645,12 @@ translate_sub_tlist(List *tlist, int relid) * create_gather_path * Creates a path corresponding to a gather scan, returning the * pathnode. + * + * 'rows' may optionally be set to override row estimates from other sources. */ GatherPath * create_gather_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, - Relids required_outer) + PathTarget *target, Relids required_outer, double *rows) { GatherPath *pathnode = makeNode(GatherPath); @@ -1656,7 +1658,7 @@ create_gather_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, pathnode->path.pathtype = T_Gather; pathnode->path.parent = rel; - pathnode->path.pathtarget = rel->reltarget; + pathnode->path.pathtarget = target; pathnode->path.param_info = get_baserel_parampathinfo(root, rel, required_outer); pathnode->path.parallel_aware = false; @@ -1674,7 +1676,7 @@ create_gather_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, pathnode->single_copy = true; } - cost_gather(pathnode, root, rel, pathnode->path.param_info); + cost_gather(pathnode, root, rel, pathnode->path.param_info, rows); return pathnode; } @@ -2417,6 +2419,8 @@ create_upper_unique_path(PlannerInfo *root, * 'qual' is the HAVING quals if any * 'aggcosts' contains cost info about the aggregate functions to be computed * 'numGroups' is the estimated number of groups (1 if not grouping) + * 'combineStates' is set to true if the Agg node should combine agg states + * 'finalizeAggs' is set to false if the Agg node should not call the finalfn */ AggPath * create_agg_path(PlannerInfo *root, @@ -2427,7 +2431,9 @@ create_agg_path(PlannerInfo *root, List *groupClause, List *qual, const AggClauseCosts *aggcosts, - double numGroups) + double numGroups, + bool combineStates, + bool finalizeAggs) { AggPath *pathnode = makeNode(AggPath); @@ -2450,6 +2456,8 @@ create_agg_path(PlannerInfo *root, pathnode->numGroups = numGroups; pathnode->groupClause = groupClause; pathnode->qual = qual; + pathnode->finalizeAggs = finalizeAggs; + pathnode->combineStates = combineStates; cost_agg(&pathnode->path, root, aggstrategy, aggcosts, |