From: Robert Haas <rhaas@postgresql.org>
To: pgsql-committers@postgresql.org
Subject: pgsql: Pass InitPlan values to workers via Gather (Merge).
Date: Thu, 16 Nov 2017 17:06:55 +0000
Message-ID: <E1eFNcu-0006LY-04@gemulon.postgresql.org> (raw)
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(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: rhaas@postgresql.org
Subject: Re: pgsql: Pass InitPlan values to workers via Gather (Merge).
In-Reply-To: <E1eFNcu-0006LY-04@gemulon.postgresql.org>
References: <E1eFNcu-0006LY-04@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox