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: Postpone some stuff out of ExecInitModifyTable.
Date: Tue, 06 Apr 2021 19:57:42 +0000
Message-ID: <E1lTrpW-0000to-ET@gemulon.postgresql.org> (raw)

Postpone some stuff out of ExecInitModifyTable.

Arrange to do some things on-demand, rather than immediately during
executor startup, because there's a fair chance of never having to do
them at all:

* Don't open result relations' indexes until needed.

* Don't initialize partition tuple routing, nor the child-to-root
tuple conversion map, until needed.

This wins in UPDATEs on partitioned tables when only some of the
partitions will actually receive updates; with larger partition
counts the savings is quite noticeable.  Also, we can remove some
sketchy heuristics in ExecInitModifyTable about whether to set up
tuple routing.

Also, remove execPartition.c's private hash table tracking which
partitions were already opened by the ModifyTable node.  Instead
use the hash added to ModifyTable itself by commit 86dc90056.

To allow lazy computation of the conversion maps, we now set
ri_RootResultRelInfo in all child ResultRelInfos.  We formerly set it
only in some, not terribly well-defined, cases.  This has user-visible
side effects in that now more error messages refer to the root
relation instead of some partition (and provide error data in the
root's column order, too).  It looks to me like this is a strict
improvement in consistency, so I don't have a problem with the
output changes visible in this commit.

Extracted from a larger patch, which seemed to me to be too messy
to push in one commit.

Amit Langote, reviewed at different times by Heikki Linnakangas and
myself

Discussion: https://postgr.es/m/CA+HiwqG7ZruBmmih3wPsBZ4s0H2EhywrnXEduckY5Hr3fWzPWA@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
src/backend/commands/copyfrom.c          |   2 +-
src/backend/commands/trigger.c           |   2 +-
src/backend/executor/execMain.c          |   8 +
src/backend/executor/execPartition.c     | 183 ++++++-----------------
src/backend/executor/execUtils.c         |  26 ++++
src/backend/executor/nodeModifyTable.c   | 247 ++++++++++++++++---------------
src/backend/replication/logical/worker.c |   2 +-
src/include/executor/execPartition.h     |   1 -
src/include/executor/executor.h          |   9 +-
src/include/nodes/execnodes.h            |   6 +-
src/test/regress/expected/inherit.out    |   2 +-
src/test/regress/expected/privileges.out |   2 +-
src/test/regress/expected/update.out     |  12 +-
13 files changed, 235 insertions(+), 267 deletions(-)



Message-ID: <E1lTrpW-0000to-ET@gemulon.postgresql.org>
Permalink:  ../E1lTrpW-0000to-ET@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lTrpW-0000to-ET@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: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Postpone some stuff out of ExecInitModifyTable.
  In-Reply-To: <E1lTrpW-0000to-ET@gemulon.postgresql.org>
  References: <E1lTrpW-0000to-ET@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