pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Haas <rhaas@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: pg_plan_advice: Refactor to invent pgpa_planner_info
Date: Thu, 26 Mar 2026 16:06:10 +0000
Message-ID: <E1w5nDl-001Z4s-2r@gemulon.postgresql.org> (raw)

pg_plan_advice: Refactor to invent pgpa_planner_info

pg_plan_advice tracks two pieces of per-PlannerInfo data: (1) for each
RTI, the corresponding relation identifier, for purposes of
cross-checking those calculations against the final plan; and (2) the
set of semijoins seen during planning for which the strategy of making
one side unique was considered. The former is tracked using a hash
table that uses <plan_name, RTI> as the key, and the latter is
tracked using a List of <plan_name, relids>.

It seems better to track both of these things in the same way and
to try to reuse some code instead of having everything be completely
separate, so invent pgpa_planner_info; we'll create one every time we
see a new PlannerInfo and need to associate some data with it, and
we'll use the plan_name field to distinguish between PlannerInfo
objects, as it should always be unique. Then, refactor the two
systems mentioned above to use this new infrastructure.

(Note that the adjustment in pgpa_plan_walker is necessary in order
to avoid spuriously triggering the sanity check in that function,
in the case where a pgpa_planner_info is created for a purpose not
related to sj_unique_rels.)

Discussion: https://postgr.es/m/CA+TgmoaK=4w7-qknUo3QhUJ53pXZq=c=KgZmRyD+k7ytqfmgSg@mail.gmail.com
Reviewed-by: Lukas Fittl <lukas@fittl.com>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5dcb15e89af2d9fbc3b038c2ea420905b279fdaf

Modified Files
--------------
contrib/pg_plan_advice/pgpa_planner.c | 266 +++++++++++++++-------------------
contrib/pg_plan_advice/pgpa_planner.h |  38 +++++
contrib/pg_plan_advice/pgpa_walker.c  |  36 +++--
contrib/pg_plan_advice/pgpa_walker.h  |  20 +--
src/tools/pgindent/typedefs.list      |   4 +-
5 files changed, 180 insertions(+), 184 deletions(-)



Message-ID: <E1w5nDl-001Z4s-2r@gemulon.postgresql.org>
Permalink:  ../E1w5nDl-001Z4s-2r@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1w5nDl-001Z4s-2r@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: rhaas@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: pg_plan_advice: Refactor to invent pgpa_planner_info
  In-Reply-To: <E1w5nDl-001Z4s-2r@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