Fix parallel query so it doesn't spoil row estimates above Gather.
authorRobert Haas
Sat, 1 Apr 2017 01:01:20 +0000 (21:01 -0400)
committerRobert Haas
Sat, 1 Apr 2017 01:10:30 +0000 (21:10 -0400)
commitfb1879c374581c0f0e251e94c0087c8385b91f5b
tree0b215b2ffd203f8e546fe250c37d2678fc094520
parent9b6e8d8f86acde571d967f85c8b8ae695a3ddba8
Fix parallel query so it doesn't spoil row estimates above Gather.

Commit 45be99f8cd5d606086e0a458c9c72910ba8a613d removed GatherPath's
num_workers field, but this is entirely bogus.  Normally, a path's
parallel_workers flag is supposed to indicate the number of workers
that it wants, and should be 0 for a non-partial path.  In that
commit, I mistakenly thought that GatherPath could also use that field
to indicate the number of workers that it would try to start, but
that's disastrous, because then it can propagate up to higher nodes in
the plan tree, which will then get incorrect rowcounts because the
parallel_workers flag is involved in computing those values.  Repair
by 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
src/backend/nodes/outfuncs.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/util/pathnode.c
src/include/nodes/relation.h