pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Amit Langote <amitlan@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Move PartitionPruneInfo out of plan nodes into PlannedStmt
Date: Thu, 30 Jan 2025 02:58:47 +0000
Message-ID: <E1tdKlT-004KnS-LP@gemulon.postgresql.org> (raw)

Move PartitionPruneInfo out of plan nodes into PlannedStmt

This moves PartitionPruneInfo from plan nodes to PlannedStmt,
simplifying traversal by centralizing all PartitionPruneInfo
structures in a single list in it, which holds all instances for the
main query and its subqueries. Instead of plan nodes (Append or
MergeAppend) storing PartitionPruneInfo pointers, they now reference
an index in this list.

A bitmapset field is added to PartitionPruneInfo to store the RT
indexes corresponding to the apprelids field in Append or MergeAppend.
This allows execution pruning logic to verify that it operates on the
correct plan node, mainly to facilitate debugging.

Duplicated code in set_append_references() and
set_mergeappend_references() is refactored into a new function,
register_pruneinfo(). This updates RT indexes by applying rtoffet
and adds PartitionPruneInfo to the global list in PlannerGlobal.

By allowing pruning to be performed without traversing the plan tree,
this change lays the groundwork for runtime initial pruning to occur
independently of plan tree initialization.

Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org> (earlier version)
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://postgr.es/m/CA+HiwqFGkMSge6TgC9KQzde0ohpAycLQuV7ooitEEpbKB0O_mg@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
src/backend/executor/execMain.c         |   1 +
src/backend/executor/execParallel.c     |   1 +
src/backend/executor/execPartition.c    |  17 +++++-
src/backend/executor/execUtils.c        |   1 +
src/backend/executor/nodeAppend.c       |   5 +-
src/backend/executor/nodeMergeAppend.c  |   5 +-
src/backend/optimizer/plan/createplan.c |  23 +++----
src/backend/optimizer/plan/planner.c    |   1 +
src/backend/optimizer/plan/setrefs.c    | 103 +++++++++++++++++++-------------
src/backend/partitioning/partprune.c    |  19 ++++--
src/include/executor/execPartition.h    |   3 +-
src/include/nodes/execnodes.h           |   1 +
src/include/nodes/pathnodes.h           |   6 ++
src/include/nodes/plannodes.h           |  16 +++--
src/include/partitioning/partprune.h    |   8 +--
15 files changed, 137 insertions(+), 73 deletions(-)



Message-ID: <E1tdKlT-004KnS-LP@gemulon.postgresql.org>
Permalink:  ../E1tdKlT-004KnS-LP@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1tdKlT-004KnS-LP@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: amitlan@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Move PartitionPruneInfo out of plan nodes into PlannedStmt
  In-Reply-To: <E1tdKlT-004KnS-LP@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