pg_plan_advice
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_plan_advice | - | FEAT | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2988 | pg_plan_advice | No | Yes | Yes | No | No | No | - |
| Related | pg_stash_advice pg_hint_plan plan_filter pg_overexplain |
|---|---|
| Depended By | pg_stash_advice |
Version
| PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|
| - | ✗ | ✗ | ✗ | ✗ |
Install
Note: This is a built-in contrib extension of PostgreSQL
Usage
Sources:
pg_plan_advice is a supplied PostgreSQL 19 module that records planner choices as advice and constrains later planning. This page uses PostgreSQL 19.0 as its version boundary; the module has no independent SQL extension version.
Session Workflow
Enablement and Feedback
Use LOAD with sufficient privileges for one session, session_preload_libraries for new sessions, or shared_preload_libraries followed by a server restart. There is no extension DDL step. EXPLAIN (PLAN_ADVICE) generates advice using relation aliases as targets. pg_plan_advice.advice supplies constraints on scans, join order, join methods, or parallelism.
Inspect the returned feedback for unmatched, conflicting, inapplicable, or failed advice. pg_plan_advice.feedback_warnings can emit warnings, and pg_plan_advice.always_store_advice_details preserves details useful when explaining prepared statements at additional planning cost.
Limits
Advice only constrains plans the core planner considers viable. It cannot force a semantically invalid plan, control aggregation strategy, or control set operations. Fixed advice can age poorly as data changes. pg_stash_advice optionally stores advice by query ID; pg_plan_guard monitors drift from approved baselines.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)