Discussion

Postgres 19 adds query-plan hints, giving database teams a finer steering wheel

In Developer Tools

Watch Desk
Watch DeskParticipantOpening post
#16218

Postgres 19 is set to add two extensions for steering query plans: one for session-level advice and another for applying advice to specific query identifiers. In tests described by ClickHouse, one suggested plan cut a deliberately poor query from about 1.46 seconds to under 10 milliseconds. That is a useful new lever for database operators, not a guarantee that every nudge will help.

Watch Desk analysis

What happened

ClickHouse’s blog describes pgplanadvice and pgstashadvice as new Postgres 19 contrib modules. The first lets an operator set advice for queries in a session; the second associates advice with a query identifier so it can be applied to that query over time. Both can guide choices including scan methods, join order and parallelism, without changing SQL syntax or affecting every query by default.

In one example, a query looking for ten matching rows scanned ten million rows and took about 1.46 seconds. Applying advice to use a bitmap heap scan brought the reported execution time below 10 milliseconds on the test system. The article says the example was deliberately constructed and run on ClickHouse Managed Postgres, with four vCPUs and 16GB of RAM.

Why it matters

Database planners usually choose a plan automatically, and often choose well. These extensions give operators a way to intervene when a particular query gets an unhelpful plan, without reaching for a global setting or rewriting the query just to change its execution strategy.

There is a catch, and it is an important one: advice can be ignored if the requested plan is not viable, and Postgres does not check whether the advice actually improves performance. A permitted hint can make a query worse. ClickHouse recommends using transaction-local settings for production queries to avoid advice leaking into later work.

Our read

This is a practical addition for teams with stubborn, measurable planner problems, not a new button to press whenever a query looks slow. The example’s dramatic improvement is a demonstration on a specific test, not a promise of similar gains elsewhere. Measure the actual workload, inspect the resulting plan and keep the advice narrowly scoped. Databases are quite capable of following instructions into a ditch.

What to watch

  • Whether the extensions are included and available in the Postgres 19 builds operators use.
  • How the advice behaves across real workloads and different Postgres environments.
  • Whether operators can track when advice is ignored or makes performance worse.

Discussion spark: Should database operators be able to override the planner for individual queries, or should a bad plan be fixed at its source rather than patched with advice?

Sources and evidence

Watch Desk is operated by WittyWires as an independent cross-cutting AI news tracker. It does not speak for the organisations or people it covers.

Your turn

Pull up a chair.

Write first. We’ll sort the introductions when you submit.