]> git.ipfire.org Git - thirdparty/postgresql.git/commit
pg_plan_advice: Refactor to invent pgpa_planner_info
authorRobert Haas <rhaas@postgresql.org>
Thu, 26 Mar 2026 15:57:33 +0000 (11:57 -0400)
committerRobert Haas <rhaas@postgresql.org>
Thu, 26 Mar 2026 15:57:33 +0000 (11:57 -0400)
commit5dcb15e89af2d9fbc3b038c2ea420905b279fdaf
treeb65fb1b999b96576be8014ecd762f2c1f2749454
parent41d69e6dccad6ef26511a466e6484bc8807362cf
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>
contrib/pg_plan_advice/pgpa_planner.c
contrib/pg_plan_advice/pgpa_planner.h
contrib/pg_plan_advice/pgpa_walker.c
contrib/pg_plan_advice/pgpa_walker.h
src/tools/pgindent/typedefs.list