• Sources: primary
  • Summary: PostgreSQL 19 ships pg_plan_advice, set per session, and pg_stash_advice, applied per query identifier, both working by forbidding the plans not chosen. In ClickHouse's tests, BITMAP_HEAP_SCAN cut an ORDER BY LIMIT query over clustered rows from 1,462 ms to 9.7 ms, and JOIN_ORDER(a act) cut a join with correlated filters from 3,837 ms to 20 ms. EXPLAIN with PLAN_ADVICE reports whether supplied advice matched, and the post shows stale advice can make a query slower once the data changes.
  • Why it matters: Postgres users get supported hints for the rare plans the planner gets wrong, but should scope them with SET LOCAL and recheck them as data shifts.
  • Background: The Postgres project long refused query hints, treating bad plans as planner bugs, which left users with the third-party pg_hint_plan extension or blunt enable_ settings. The planner keeps statistics per table and assumes filters on different tables are independent, so correlated columns across a join can push its row estimates off by orders of magnitude.