Add an alternative_plan_name field to PlannerInfo.
Robert Haas <rhaas@postgresql.org>
Add an alternative_plan_name field to PlannerInfo. Typically, we have only one PlannerInfo for any given subquery, but when we are considering a MinMaxAggPath or a hashed subplan, we end up creating a second PlannerInfo for the same portion of the query, with a clone of the original range table. In fact, in the MinMaxAggPath case, we might end up creating several clones, one per aggregate. At present, there's no easy way for a plugin, such as pg_plan_advice, to understand the relationships between the original range table and the copies of it that are created in these cases. To fix, add an alternative_plan_name field to PlannerInfo. For a hashed subplan, this is the plan name for the non-hashed alternative; for minmax aggregates, this is the plan_name from the parent PlannerInfo; otherwise, it's the same as plan_name. Discussion: http://postgr.es/m/CA+TgmoYuWmN-00Ec5pY7zAcpSFQUQLbgAdVWGR9kOR-HM-fHrA@mail.gmail.com Reviewed-by: Lukas Fittl <lukas@fittl.com>
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/optimizer/path/allpaths.c | modified | +1 −1 |
| src/backend/optimizer/plan/planagg.c | modified | +1 −0 |
| src/backend/optimizer/plan/planner.c | modified | +11 −4 |
| src/backend/optimizer/plan/subselect.c | modified | +3 −3 |
| src/backend/optimizer/prep/prepjointree.c | modified | +1 −0 |
| src/backend/optimizer/prep/prepunion.c | modified | +1 −1 |
| src/include/nodes/pathnodes.h | modified | +12 −0 |
| src/include/optimizer/planner.h | modified | +1 −0 |
Discussion
- pg_plan_advice 219 messages · 2025-10-30 → 2026-06-10