pg_idx_advisor
pg_idx_advisor · PostgreSQL index advisor
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100128 | pg_idx_advisor | pg_idx_advisor | 0.1.2 | FEAT | PostgreSQL | C |
PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18
| Relationships | |
|---|---|
| Requires | plpgsql |
Usage
Sources:
pg_idx_advisor is a deprecated planner-hook extension that compares an EXPLAIN plan with plans using hypothetical candidate indexes and emits CREATE INDEX recommendations. Upstream says it is no longer updated and directs users to HypoPG. Keep it only for reproducing historical behavior.
Core Workflow
Create the catalog table, then load the library in the session before running EXPLAIN:
The extension prints original and hypothetical plans and, unless read-only mode is enabled, stores recommendations in index_advisory.
Important Objects
index_advisorystores relation OID, indexed attributes, estimated benefit and size, expression or predicate, source query, and recommendation text.index_adviser.colslists columns considered for partial indexes.index_adviser.schemaselects the schema containing the advisory table.index_adviser.read_onlydisables table inserts and prints advice only.index_adviser.text_pattern_opspermits text-pattern operator classes.index_adviser.composit_max_colslimits columns in a composite candidate.
Operational Notes
Loading the library replaces planner and EXPLAIN hooks for that backend and uses old PostgreSQL virtual-index internals. Recommendations are cost-model hypotheses, not proof that an index helps under real data, writes, cache state, or concurrency. Review locking, build time, storage, write amplification, duplicate indexes, and partial predicates before applying any emitted SQL. Prefer a maintained HypoPG-based workflow on supported PostgreSQL versions.