Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite06a389

Browse files
committed
Support parallel aggregation.
Parallel workers can now partially aggregate the data and pass thetransition values back to the leader, which can combine the partialresults 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.
1 parent7fa0064 commite06a389

File tree

23 files changed

+911
-83
lines changed

23 files changed

+911
-83
lines changed

‎src/backend/executor/execQual.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4515,6 +4515,14 @@ ExecInitExpr(Expr *node, PlanState *parent)
45154515
if (parent&&IsA(parent,AggState))
45164516
{
45174517
AggState*aggstate= (AggState*)parent;
4518+
Aggref*aggref= (Aggref*)node;
4519+
4520+
if (aggstate->finalizeAggs&&
4521+
aggref->aggoutputtype!=aggref->aggtype)
4522+
{
4523+
/* planner messed up */
4524+
elog(ERROR,"Aggref aggoutputtype must match aggtype");
4525+
}
45184526

45194527
aggstate->aggs=lcons(astate,aggstate->aggs);
45204528
aggstate->numaggs++;

‎src/backend/nodes/copyfuncs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,7 @@ _copyAggref(const Aggref *from)
12331233

12341234
COPY_SCALAR_FIELD(aggfnoid);
12351235
COPY_SCALAR_FIELD(aggtype);
1236+
COPY_SCALAR_FIELD(aggoutputtype);
12361237
COPY_SCALAR_FIELD(aggcollid);
12371238
COPY_SCALAR_FIELD(inputcollid);
12381239
COPY_NODE_FIELD(aggdirectargs);

‎src/backend/nodes/equalfuncs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ _equalAggref(const Aggref *a, const Aggref *b)
192192
{
193193
COMPARE_SCALAR_FIELD(aggfnoid);
194194
COMPARE_SCALAR_FIELD(aggtype);
195+
COMPARE_SCALAR_FIELD(aggoutputtype);
195196
COMPARE_SCALAR_FIELD(aggcollid);
196197
COMPARE_SCALAR_FIELD(inputcollid);
197198
COMPARE_NODE_FIELD(aggdirectargs);

‎src/backend/nodes/nodeFuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ exprType(const Node *expr)
5757
type= ((constParam*)expr)->paramtype;
5858
break;
5959
caseT_Aggref:
60-
type= ((constAggref*)expr)->aggtype;
60+
type= ((constAggref*)expr)->aggoutputtype;
6161
break;
6262
caseT_GroupingFunc:
6363
type=INT4OID;

‎src/backend/nodes/outfuncs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,7 @@ _outAggref(StringInfo str, const Aggref *node)
10331033

10341034
WRITE_OID_FIELD(aggfnoid);
10351035
WRITE_OID_FIELD(aggtype);
1036+
WRITE_OID_FIELD(aggoutputtype);
10361037
WRITE_OID_FIELD(aggcollid);
10371038
WRITE_OID_FIELD(inputcollid);
10381039
WRITE_NODE_FIELD(aggdirectargs);

‎src/backend/nodes/readfuncs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ _readAggref(void)
552552

553553
READ_OID_FIELD(aggfnoid);
554554
READ_OID_FIELD(aggtype);
555+
READ_OID_FIELD(aggoutputtype);
555556
READ_OID_FIELD(aggcollid);
556557
READ_OID_FIELD(inputcollid);
557558
READ_NODE_FIELD(aggdirectargs);

‎src/backend/optimizer/path/allpaths.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1968,7 +1968,8 @@ generate_gather_paths(PlannerInfo *root, RelOptInfo *rel)
19681968
*/
19691969
cheapest_partial_path=linitial(rel->partial_pathlist);
19701970
simple_gather_path= (Path*)
1971-
create_gather_path(root,rel,cheapest_partial_path,NULL);
1971+
create_gather_path(root,rel,cheapest_partial_path,rel->reltarget,
1972+
NULL,NULL);
19721973
add_path(rel,simple_gather_path);
19731974
}
19741975

‎src/backend/optimizer/path/costsize.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,16 +350,22 @@ cost_samplescan(Path *path, PlannerInfo *root,
350350
*
351351
* 'rel' is the relation to be operated upon
352352
* 'param_info' is the ParamPathInfo if this is a parameterized path, else NULL
353+
* 'rows' may be used to point to a row estimate; if non-NULL, it overrides
354+
* both 'rel' and 'param_info'. This is useful when the path doesn't exactly
355+
* correspond to any particular RelOptInfo.
353356
*/
354357
void
355358
cost_gather(GatherPath*path,PlannerInfo*root,
356-
RelOptInfo*rel,ParamPathInfo*param_info)
359+
RelOptInfo*rel,ParamPathInfo*param_info,
360+
double*rows)
357361
{
358362
Coststartup_cost=0;
359363
Costrun_cost=0;
360364

361365
/* Mark the path with the correct row estimate */
362-
if (param_info)
366+
if (rows)
367+
path->path.rows=*rows;
368+
elseif (param_info)
363369
path->path.rows=param_info->ppi_rows;
364370
else
365371
path->path.rows=rel->rows;
@@ -1751,6 +1757,8 @@ cost_agg(Path *path, PlannerInfo *root,
17511757
{
17521758
/* must be AGG_HASHED */
17531759
startup_cost=input_total_cost;
1760+
if (!enable_hashagg)
1761+
startup_cost+=disable_cost;
17541762
startup_cost+=aggcosts->transCost.startup;
17551763
startup_cost+=aggcosts->transCost.per_tuple*input_tuples;
17561764
startup_cost+= (cpu_operator_cost*numGroupCols)*input_tuples;

‎src/backend/optimizer/plan/createplan.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,8 +1575,8 @@ create_agg_plan(PlannerInfo *root, AggPath *best_path)
15751575

15761576
plan=make_agg(tlist,quals,
15771577
best_path->aggstrategy,
1578-
false,
1579-
true,
1578+
best_path->combineStates,
1579+
best_path->finalizeAggs,
15801580
list_length(best_path->groupClause),
15811581
extract_grouping_cols(best_path->groupClause,
15821582
subplan->targetlist),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp