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