PostgreSQL 19 Introduces pg_plan_advice, Its First Native Query Plan Control Tool
PostgreSQL 19 ships pg_plan_advice, a contrib module that allows database administrators to capture and enforce query planner decisions without embedding hints inside SQL query text. The feature addresses a long-standing problem where inaccurate statistics from ANALYZE sampling can cause the planner to choose drastically slower execution plans. A real-world example from Clerk in February 2026 illustrated the risk: a missampled NULL-heavy column led to a catastrophic plan change that saturated their database for roughly 90 minutes. PostgreSQL had historically resisted query hints due to concerns about maintainability, silent breakage across upgrades, and discouraging proper bug reporting, but pg_plan_advice is designed to sidestep those issues by storing plan guidance as auditable database configuration rather than SQL comments. The module, authored by Robert Haas, keeps query text clean and provides a structured, removable mechanism for plan stabilization — the first of its kind built into the PostgreSQL core.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in