pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Haas <rhaas@postgresql.org>
To: pgsql-committers@postgresql.org
Subject: pgsql: Allow for parallel execution whenever ExecutorRun() is done only
Date: Thu, 23 Mar 2017 17:23:01 +0000
Message-ID: <E1cr6Rx-0000yk-32@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Allow for parallel execution whenever ExecutorRun() is done only once.

Previously, it was unsafe to execute a plan in parallel if
ExecutorRun() might be called with a non-zero row count.  However,
it's quite easy to fix things up so that we can support that case,
provided that it is known that we will never call ExecutorRun() a
second time for the same QueryDesc.  Add infrastructure to signal
this, and cross-checks to make sure that a caller who claims this is
true doesn't later reneg.

While that pattern never happens with queries received directly from a
client -- there's no way to know whether multiple Execute messages
will be sent unless the first one requests all the rows -- it's pretty
common for queries originating from procedural languages, which often
limit the result to a single tuple or to a user-specified number of
tuples.

This commit doesn't actually enable parallelism in any additional
cases, because currently none of the places that would be able to
benefit from this infrastructure pass CURSOR_OPT_PARALLEL_OK in the
first place, but it makes it much more palatable to pass
CURSOR_OPT_PARALLEL_OK in places where we currently don't, because it
eliminates some cases where we'd end up having to run the parallel
plan serially.

Patch by me, based on some ideas from Rafia Sabih and corrected by
Rafia Sabih based on feedback from Dilip Kumar and myself.

Discussion: http://postgr.es/m/CA+TgmobXEhvHbJtWDuPZM9bVSLiTj-kShxQJ2uM5GPDze9fRYA@mail.gmail.com

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/691b8d59281b5177f16fe80858df921f77a8e955

Modified Files
--------------
contrib/auto_explain/auto_explain.c             |  9 +++---
contrib/pg_stat_statements/pg_stat_statements.c |  9 +++---
src/backend/commands/copy.c                     |  2 +-
src/backend/commands/createas.c                 |  2 +-
src/backend/commands/explain.c                  |  2 +-
src/backend/commands/extension.c                |  2 +-
src/backend/commands/matview.c                  |  2 +-
src/backend/commands/portalcmds.c               |  2 +-
src/backend/commands/prepare.c                  |  2 +-
src/backend/executor/execMain.c                 | 38 +++++++++++++++++--------
src/backend/executor/execParallel.c             |  2 +-
src/backend/executor/functions.c                |  2 +-
src/backend/executor/spi.c                      |  2 +-
src/backend/tcop/postgres.c                     |  2 ++
src/backend/tcop/pquery.c                       | 20 ++++++++++---
src/include/executor/execdesc.h                 |  3 ++
src/include/executor/executor.h                 |  7 +++--
src/include/tcop/pquery.h                       |  2 +-
src/include/utils/portal.h                      |  1 +
19 files changed, 73 insertions(+), 38 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Message-ID: <E1cr6Rx-0000yk-32@gemulon.postgresql.org>
Permalink:  ../E1cr6Rx-0000yk-32@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1cr6Rx-0000yk-32@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 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: Allow for parallel execution whenever ExecutorRun() is done only
  In-Reply-To: <E1cr6Rx-0000yk-32@gemulon.postgresql.org>
  References: <E1cr6Rx-0000yk-32@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