pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow plan nodes with initPlans to be considered parallel-safe.
Date: Fri, 14 Jul 2023 15:46:42 +0000
Message-ID: <E1qKL0E-000Lio-3u@gemulon.postgresql.org> (raw)

Allow plan nodes with initPlans to be considered parallel-safe.

If the plan itself is parallel-safe, and the initPlans are too,
there's no reason anymore to prevent the plan from being marked
parallel-safe.  That restriction (dating to commit ab77a5a45) was
really a special case of the fact that we couldn't transmit subplans
to parallel workers at all.  We fixed that in commit 5e6d8d2bb and
follow-ons, but this case never got addressed.

We still forbid attaching initPlans to a Gather node that's
inserted pursuant to debug_parallel_query = regress.  That's because,
when we hide the Gather from EXPLAIN output, we'd hide the initPlans
too, causing cosmetic regression diffs.  It seems inadvisable to
kluge EXPLAIN to the extent required to make the output look the
same, so just don't do it in that case.

Along the way, this also takes care of some sloppiness about updating
path costs to match when we move initplans from one place to another
during createplan.c and setrefs.c.  Since all the planning decisions
are already made by that point, this is just cosmetic; but it seems
good to keep EXPLAIN output consistent with where the initplans are.

The diff in query_planner() might be worth remarking on.  I found that
one because after fixing things to allow parallel-safe initplans, one
partition_prune test case changed plans (as shown in the patch) ---
but only when debug_parallel_query was active.  The reason proved to
be that we only bothered to mark Result nodes as potentially
parallel-safe when debug_parallel_query is on.  This neglects the fact
that parallel-safety may be of interest for a sub-query even though
the Result itself doesn't parallelize.

Discussion: https://postgr.es/m/1129530.1681317832@sss.pgh.pa.us

Branch
------
master

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

Modified Files
--------------
src/backend/optimizer/plan/createplan.c       | 15 +++--
src/backend/optimizer/plan/planmain.c         | 15 +++--
src/backend/optimizer/plan/planner.c          | 36 +++++++++---
src/backend/optimizer/plan/setrefs.c          | 32 ++++++----
src/backend/optimizer/plan/subselect.c        | 84 +++++++++++++++++++++------
src/backend/optimizer/util/pathnode.c         | 18 +++++-
src/include/optimizer/subselect.h             |  3 +
src/test/regress/expected/partition_prune.out | 37 +++++-------
8 files changed, 169 insertions(+), 71 deletions(-)



Message-ID: <E1qKL0E-000Lio-3u@gemulon.postgresql.org>
Permalink:  ../E1qKL0E-000Lio-3u@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1qKL0E-000Lio-3u@gemulon.postgresql.org

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Allow plan nodes with initPlans to be considered parallel-safe.
  In-Reply-To: <E1qKL0E-000Lio-3u@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