Support Parallel Append plan nodes

Enterprise / PostgreSQL - Robert Haas [postgresql.org] - 5 December 2017 22:28 EST

When we create an Append node, we can spread out the workers over the subplans instead of piling on to each subplan one at a time, which should typically be a bit more efficient, both because the startup cost of any plan executed entirely by one worker is paid only once and also because of reduced contention. We can also construct Append plans using a mix of partial and non-partial subplans, which may allow for parallelism in places that otherwise couldn't support it. Unfortunately, this patch doesn't handle the important case of parallelizing UNION ALL by running each branch in a separate worker; the executor infrastructure is added here, but more planner work is needed.

Amit Khandekar, Robert Haas, Amul Sul, reviewed and tested by Ashutosh Bapat, Amit Langote, Rafia Sabih, Amit Kapila, and Rajkumar Raghuwanshi.

Discussion: http://postgr.es/m/CAJ3gD9dy0K_E8r727heqXoBmWZ83HwLFwdcaSSmBQ1+S+vRuUQ@mail.gmail.com

ab72716778 Support Parallel Append plan nodes.
doc/src/sgml/config.sgml | 14 ++
doc/src/sgml/monitoring.sgml | 7 +-
src/backend/executor/execParallel.c | 19 ++
src/backend/executor/nodeAppend.c | 331 +++++++++++++++++++++-----
src/backend/nodes/copyfuncs.c | 1 +
src/backend/nodes/list.c | 38 +++
src/backend/nodes/outfuncs.c | 1 +
src/backend/nodes/readfuncs.c | 1 +
src/backend/optimizer/path/allpaths.c | 216 ++++++++++++++---
src/backend/optimizer/path/costsize.c | 164 +++++++++++++
src/backend/optimizer/path/joinrels.c | 3 +-
src/backend/optimizer/plan/createplan.c | 10 +-
src/backend/optimizer/plan/planner.c | 5 +-
src/backend/optimizer/prep/prepunion.c | 7 +-
src/backend/optimizer/util/pathnode.c | 88 +++++--
src/backend/storage/lmgr/lwlock.c | 1 +
src/backend/utils/misc/guc.c | 9 +
src/backend/utils/misc/postgresql.conf.sample | 1 +
src/include/executor/nodeAppend.h | 5 +
src/include/nodes/execnodes.h | 14 +-
src/include/nodes/pg_list.h | 3 +
src/include/nodes/plannodes.h | 1 +
src/include/nodes/relation.h | 6 +
src/include/optimizer/cost.h | 2 +
src/include/optimizer/pathnode.h | 9 +-
src/include/storage/lwlock.h | 1 +
src/test/regress/expected/inherit.out | 2 +
src/test/regress/expected/select_parallel.out | 91 ++++++-
src/test/regress/expected/sysviews.out | 3 +-
src/test/regress/sql/inherit.sql | 2 +
src/test/regress/sql/select_parallel.sql | 33 ++-
31 files changed, 959 insertions(+), 129 deletions(-)

Upstream: git.postgresql.org


  • Share