pgsql: Pass InitPlan values to workers via Gather (Merge). - Mailing list pgsql-committers

From Robert Haas
Subject pgsql: Pass InitPlan values to workers via Gather (Merge).
Date
Msg-id E1eFNcu-0006LY-04@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Pass InitPlan values to workers via Gather (Merge).

If a PARAM_EXEC parameter is used below a Gather (Merge) but the InitPlan
that computes it is attached to or above the Gather (Merge), force the
value to be computed before starting parallelism and pass it down to all
workers.  This allows us to use parallelism in cases where it previously
would have had to be rejected as unsafe.  We do - in this case - lose the
optimization that the value is only computed if it's actually used.  An
alternative strategy would be to have the first worker that needs the value
compute it, but one downside of that approach is that we'd then need to
select a parallel-safe path to compute the parameter value; it couldn't for
example contain a Gather (Merge) node.  At some point in the future, we
might want to consider both approaches.

Independent of that consideration, there is a great deal more work that
could be done to make more kinds of PARAM_EXEC parameters parallel-safe.
This infrastructure could be used to allow a Gather (Merge) on the inner
side of a nested loop (although that's not a very appealing plan) and
cases where the InitPlan is attached below the Gather (Merge) could be
addressed as well using various techniques.  But this is a good start.

Amit Kapila, reviewed and revised by me.  Reviewing and testing from
Kuntal Ghosh, Haribabu Kommi, and Tushar Ahuja.

Discussion: http://postgr.es/m/CAA4eK1LV0Y1AUV4cUCdC+sYOx0Z0-8NAJ2Pd9=UKsbQ5Sr7+JQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e89a71fb449af2ef74f47be1175f99956cf21524

Modified Files
--------------
src/backend/commands/explain.c                |  34 ++++
src/backend/executor/execExprInterp.c         |  27 ++++
src/backend/executor/execParallel.c           | 219 ++++++++++++++++++++++++--
src/backend/executor/nodeGather.c             |   4 +-
src/backend/executor/nodeGatherMerge.c        |   4 +-
src/backend/nodes/copyfuncs.c                 |   2 +
src/backend/nodes/outfuncs.c                  |   3 +
src/backend/nodes/readfuncs.c                 |   2 +
src/backend/optimizer/plan/createplan.c       |   1 +
src/backend/optimizer/plan/planner.c          |   8 +
src/backend/optimizer/plan/setrefs.c          |  51 +++++-
src/backend/optimizer/util/clauses.c          |  24 ++-
src/include/executor/execExpr.h               |   1 +
src/include/executor/execParallel.h           |   6 +-
src/include/nodes/plannodes.h                 |   4 +
src/test/regress/expected/select_parallel.out |  35 ++++
src/test/regress/sql/select_parallel.sql      |  17 ++
17 files changed, 419 insertions(+), 23 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Define _WINSOCK_DEPRECATED_NO_WARNINGS in all MSVC builds.
Next
From: Robert Haas
Date:
Subject: pgsql: Update postgresql.conf.sample to match pg_settingsclassificaito