RC RANDOM CHAOS

Postgres 19 Finally Adds Query Hints — Just Don't Call Them That

· via Hacker News

Original source

Looking Forward to Postgres 19: Query Hints

Hacker News →

After two decades of insisting it would never happen, Postgres 19 ships query hints through two new contrib modules: pg_plan_advice and pg_stash_advice. The community famously refused Oracle-style hints, citing maintenance burden, upgrade fragility, and the way they discourage real fixes — yet practitioners had long resorted to workarounds like toggling enable_seqscan or injecting OFFSET 0 to coerce the planner anyway.

Robert Haas, who argued for hints back in a fiery 2010 mailing-list thread, authored both modules and designed them to address every historical objection. Advice lives outside the SQL text (set via GUC or a query-ID-keyed stash), only constrains the planner’s existing search space rather than overriding it, and degrades gracefully by marking nodes Disabled when advice goes stale. EXPLAIN can emit advice strings that reproduce the current plan, so users don’t have to learn the syntax from scratch.

The advice language covers scan methods (INDEX_SCAN, SEQ_SCAN, DO_NOT_SCAN), join strategies, and a JOIN_ORDER tag with parentheses for strict ordering and braces for flexible grouping. It’s a careful compromise: the planner stays in charge, but DBAs finally get a documented escape hatch for the pathological queries that statistics tweaks can’t fix.

Read the full article

Continue reading at Hacker News →

This is an AI-generated summary. Read the original for the full story.