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: Centralize executor's opening/closing of Relations for rangetabl
Date: Thu, 04 Oct 2018 18:04:01 +0000
Message-ID: <E1g87yj-0001Qs-TD@gemulon.postgresql.org> (raw)

Centralize executor's opening/closing of Relations for rangetable entries.

Create an array estate->es_relations[] paralleling the es_range_table,
and store references to Relations (relcache entries) there, so that any
given RT entry is opened and closed just once per executor run.  Scan
nodes typically still call ExecOpenScanRelation, but ExecCloseScanRelation
is no more; relation closing is now done centrally in ExecEndPlan.

This is slightly more complex than one would expect because of the
interactions with relcache references held in ResultRelInfo nodes.
The general convention is now that ResultRelInfo->ri_RelationDesc does
not represent a separate relcache reference and so does not need to be
explicitly closed; but there is an exception for ResultRelInfos in the
es_trig_target_relations list, which are manufactured by
ExecGetTriggerResultRel and have to be cleaned up by
ExecCleanUpTriggerState.  (That much was true all along, but these
ResultRelInfos are now more different from others than they used to be.)

To allow the partition pruning logic to make use of es_relations[] rather
than having its own relcache references, adjust PartitionedRelPruneInfo
to store an RT index rather than a relation OID.

Amit Langote, reviewed by David Rowley and Jesper Pedersen,
some mods by me

Discussion: https://postgr.es/m/468c85d9-540e-66a2-1dde-fec2b741e688@lab.ntt.co.jp

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9ddef36278a9f676c07d0b4d9f33fa22e48ce3b5

Modified Files
--------------
contrib/postgres_fdw/postgres_fdw.c       |  4 --
src/backend/catalog/indexing.c            |  2 +-
src/backend/commands/copy.c               |  4 +-
src/backend/executor/execMain.c           | 76 ++++++++++++++++---------------
src/backend/executor/execPartition.c      | 46 ++++---------------
src/backend/executor/execUtils.c          | 60 ++++++++++++++----------
src/backend/executor/nodeAppend.c         |  6 ---
src/backend/executor/nodeBitmapHeapscan.c |  7 ---
src/backend/executor/nodeCustom.c         |  4 --
src/backend/executor/nodeForeignscan.c    |  4 --
src/backend/executor/nodeIndexonlyscan.c  |  7 ---
src/backend/executor/nodeIndexscan.c      | 11 +----
src/backend/executor/nodeMergeAppend.c    |  6 ---
src/backend/executor/nodeSamplescan.c     |  9 +---
src/backend/executor/nodeSeqscan.c        |  9 +---
src/backend/executor/nodeTidscan.c        |  7 +--
src/backend/nodes/copyfuncs.c             |  2 +-
src/backend/nodes/outfuncs.c              |  2 +-
src/backend/nodes/readfuncs.c             |  2 +-
src/backend/optimizer/plan/setrefs.c      | 30 ++++++++++++
src/backend/partitioning/partprune.c      |  6 +--
src/backend/replication/logical/worker.c  |  1 +
src/include/executor/execPartition.h      |  1 -
src/include/executor/executor.h           |  3 +-
src/include/nodes/execnodes.h             | 11 ++++-
src/include/nodes/plannodes.h             |  2 +-
src/include/partitioning/partprune.h      |  3 --
27 files changed, 144 insertions(+), 181 deletions(-)



Message-ID: <E1g87yj-0001Qs-TD@gemulon.postgresql.org>
Permalink:  ../E1g87yj-0001Qs-TD@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1g87yj-0001Qs-TD@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: Centralize executor's opening/closing of Relations for rangetabl
  In-Reply-To: <E1g87yj-0001Qs-TD@gemulon.postgresql.org>
  References: <E1g87yj-0001Qs-TD@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