pgsql: Centralize executor's opening/closing of Relations for rangetabl

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Centralize executor's opening/closing of Relations for rangetabl
Date: 2018-10-04 18:04:01
Message-ID: E1g87yj-0001Qs-TD@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2018-10-04 19:48:23 pgsql: In the executor, use an array of pointers to access the rangetab
Previous Message Alvaro Herrera 2018-10-04 14:50:10 pgsql: Fix duplicate primary keys in partitions