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

Commitfb1879c

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 parent9b6e8d8 commitfb1879c

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
@@ -1795,6 +1795,7 @@ _outGatherPath(StringInfo str, const GatherPath *node)
17951795

17961796
WRITE_NODE_FIELD(subpath);
17971797
WRITE_BOOL_FIELD(single_copy);
1798+
WRITE_INT_FIELD(num_workers);
17981799
}
17991800

18001801
staticvoid

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

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

13961396
gather_plan=make_gather(tlist,
13971397
NIL,
1398-
best_path->path.parallel_workers,
1398+
best_path->num_workers,
13991399
best_path->single_copy,
14001400
subplan);
14011401

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,16 +1681,17 @@ create_gather_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath,
16811681
required_outer);
16821682
pathnode->path.parallel_aware= false;
16831683
pathnode->path.parallel_safe= false;
1684-
pathnode->path.parallel_workers=subpath->parallel_workers;
1684+
pathnode->path.parallel_workers=0;
16851685
pathnode->path.pathkeys=NIL;/* Gather has unordered result */
16861686

16871687
pathnode->subpath=subpath;
1688+
pathnode->num_workers=subpath->parallel_workers;
16881689
pathnode->single_copy= false;
16891690

1690-
if (pathnode->path.parallel_workers==0)
1691+
if (pathnode->num_workers==0)
16911692
{
1692-
pathnode->path.parallel_workers=1;
16931693
pathnode->path.pathkeys=subpath->pathkeys;
1694+
pathnode->num_workers=1;
16941695
pathnode->single_copy= true;
16951696
}
16961697

‎src/include/nodes/relation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,7 @@ typedef struct GatherPath
11891189
Pathpath;
11901190
Path*subpath;/* path for each worker */
11911191
boolsingle_copy;/* path must not be executed >1x */
1192+
intnum_workers;/* number of workers sought to help */
11921193
}GatherPath;
11931194

11941195
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp