Generate parallel sequential scan plans in simple cases

Enterprise / PostgreSQL - Robert Haas [postgresql.org] - 11 November 2015 08:02 UTC

Add a new flag, consider_parallel, to each RelOptInfo, indicating whether a plan for that relation could conceivably be run inside of a parallel worker. Right now, we're pretty conservative: for example, it might be possible to defer applying a parallel-restricted qual in a worker, and later do it in the leader, but right now we just don't try to parallelize access to that relation. That's probably the right decision in most cases, anyway.

Using the new flag, generate parallel sequential scan plans for plain baserels, meaning that we now have parallel sequential scan in PostgreSQL. The logic here is pretty unsophisticated right now: the costing model probably isn't right in detail, and we can't push joins beneath Gather nodes, so the number of plans that can actually benefit from this is pretty limited right now. Lots more work is needed. Nevertheless, it seems time to enable this functionality so that all this code can actually be tested easily by users and developers.

Note that, if you wish to test this functionality, it will be necessary to set max_parallel_degree to a value greater than the default of 0. Once a few more loose ends have been tidied up here, we might want to consider changing the default value of this GUC, but I'm leaving it alone for now.

Along the way, fix a bug in cost_gather: the previous coding thought that a Gather node's transfer overhead should be costed on the basis of the relation size rather than the number of tuples that actually need to be passed off to the leader.

Patch by me, reviewed in earlier versions by Amit Kapila.

80558c1 Generate parallel sequential scan plans in simple cases.
src/backend/nodes/outfuncs.c | 1 +
src/backend/optimizer/path/allpaths.c | 190 ++++++++++++++++++++++++++++++++-
src/backend/optimizer/path/costsize.c | 2 +-
src/backend/optimizer/plan/planmain.c | 12 +++
src/backend/optimizer/plan/planner.c | 9 +-
src/backend/optimizer/util/clauses.c | 183 +++++++++++++++++++++++++------
src/backend/optimizer/util/relnode.c | 21 ++++
src/backend/utils/cache/lsyscache.c | 22 ++++
src/include/nodes/relation.h | 1 +
src/include/optimizer/clauses.h | 2 +-
src/include/utils/lsyscache.h | 1 +
11 files changed, 400 insertions(+), 44 deletions(-)

Upstream: git.postgresql.org


  • Share