Date: 2026-05-20
Time: 14:00–14:50
Room: Fletcher
Level: Intermediate
PostgreSQL’s query planner attempts to estimate the runtime cost of various plans, but those estimates can be based on statistics which are sometimes misleading and can change over time. This means that the planner will sometimes switch from a good plan that runs quickly to a poor one that runs extremely slowly, sometimes without warning. At other times, even the initial choice of plan will be suboptimal. Historically, PostgreSQL has provided few ways for users to control planner behavior, making such problems difficult to prevent or resolve.
In this talk, I’ll discuss my ongoing work on pg_plan_advice, a proposed addition to PostgreSQL which aims to address this issue. pg_plan_advice is intended to serve a variety of use cases, including (1) regenerating in whole or in part a plan previously discovered to work well, (2) enforcing choice of an alternate plan that the user prefers over the one that the planner would normally select, or (3) debugging the failure of the planner to produce what the user believes to be the correct plan. In this talk, I’ll give an overview of what this module does and how it does that, what problems had to be solved in order to enable it to do those things, the current status of the patch, and the problems that remain to be solved. In addition, I’ll briefly discuss potential future features that could use this feature as scaffolding.