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: Simplify executor's determination of whether to use parallelism.
Date: Mon, 09 Dec 2024 19:38:46 +0000
Message-ID: <E1tKjaf-001umi-Q1@gemulon.postgresql.org> (raw)

Simplify executor's determination of whether to use parallelism.

Our parallel-mode code only works when we are executing a query
in full, so ExecutePlan must disable parallel mode when it is
asked to do partial execution.  The previous logic for this
involved passing down a flag (variously named execute_once or
run_once) from callers of ExecutorRun or PortalRun.  This is
overcomplicated, and unsurprisingly some of the callers didn't
get it right, since it requires keeping state that not all of
them have handy; not to mention that the requirements for it were
undocumented.  That led to assertion failures in some corner
cases.  The only state we really need for this is the existing
QueryDesc.already_executed flag, so let's just put all the
responsibility in ExecutePlan.  (It could have been done in
ExecutorRun too, leading to a slightly shorter patch -- but if
there's ever more than one caller of ExecutePlan, it seems better
to have this logic in the subroutine than the callers.)

This makes those ExecutorRun/PortalRun parameters unnecessary.
In master it seems okay to just remove them, returning the
API for those functions to what it was before parallelism.
Such an API break is clearly not okay in stable branches,
but for them we can just leave the parameters in place after
documenting that they do nothing.

Per report from Yugo Nagata, who also reviewed and tested
this patch.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/20241206062549.710dc01cf91224809dd6c0e1@sraoss.co.jp

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8a95ad3b205cfce4441bdb6cae0475e1304cc3a9

Modified Files
--------------
src/backend/executor/execMain.c | 47 ++++++++++++++++++-----------------------
src/backend/tcop/postgres.c     |  4 ++--
src/backend/tcop/pquery.c       | 13 ++++--------
src/include/executor/execdesc.h |  2 +-
src/include/utils/portal.h      |  2 +-
5 files changed, 29 insertions(+), 39 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1tKjaf-001umi-Q1@gemulon.postgresql.org>
Permalink:  ../E1tKjaf-001umi-Q1@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1tKjaf-001umi-Q1@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: Simplify executor's determination of whether to use parallelism.
  In-Reply-To: <E1tKjaf-001umi-Q1@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