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

Commit7d8f698

Browse files
committed
Fix parallel query so it doesn't spoil row estimates above Gather.
Commit45be99f removed GatherPath'snum_workers field, but this is entirely bogus. Normally, a path'sparallel_workers flag is supposed to indicate the number of workersthat it wants, and should be 0 for a non-partial path. In thatcommit, I mistakenly thought that GatherPath could also use that fieldto indicate the number of workers that it would try to start, butthat's disastrous, because then it can propagate up to higher nodes inthe plan tree, which will then get incorrect rowcounts because theparallel_workers flag is involved in computing those values. Repairby putting the separate field back.Report by Tomas Vondra. Patch by me, reviewed by Amit Kapila.Discussion:http://postgr.es/m/f91b4a44-f739-04bd-c4b6-f135bd643669@2ndquadrant.com
1 parent2113ac4 commit7d8f698

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

‎src/backend/nodes/outfuncs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,6 +1870,7 @@ _outGatherPath(StringInfo str, const GatherPath *node)
18701870

18711871
WRITE_NODE_FIELD(subpath);
18721872
WRITE_BOOL_FIELD(single_copy);
1873+
WRITE_INT_FIELD(num_workers);
18731874
}
18741875

18751876
staticvoid

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,7 @@ create_gather_plan(PlannerInfo *root, GatherPath *best_path)
14461446

14471447
gather_plan=make_gather(tlist,
14481448
NIL,
1449-
best_path->path.parallel_workers,
1449+
best_path->num_workers,
14501450
best_path->single_copy,
14511451
subplan);
14521452

‎src/backend/optimizer/util/pathnode.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,16 +1742,17 @@ create_gather_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath,
17421742
required_outer);
17431743
pathnode->path.parallel_aware= false;
17441744
pathnode->path.parallel_safe= false;
1745-
pathnode->path.parallel_workers=subpath->parallel_workers;
1745+
pathnode->path.parallel_workers=0;
17461746
pathnode->path.pathkeys=NIL;/* Gather has unordered result */
17471747

17481748
pathnode->subpath=subpath;
1749+
pathnode->num_workers=subpath->parallel_workers;
17491750
pathnode->single_copy= false;
17501751

1751-
if (pathnode->path.parallel_workers==0)
1752+
if (pathnode->num_workers==0)
17521753
{
1753-
pathnode->path.parallel_workers=1;
17541754
pathnode->path.pathkeys=subpath->pathkeys;
1755+
pathnode->num_workers=1;
17551756
pathnode->single_copy= true;
17561757
}
17571758

‎src/include/nodes/relation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,7 @@ typedef struct GatherPath
12281228
Pathpath;
12291229
Path*subpath;/* path for each worker */
12301230
boolsingle_copy;/* don't execute path more than once */
1231+
intnum_workers;/* number of workers sought to help */
12311232
}GatherPath;
12321233

12331234
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp