Recommend skip scan indexes
recommend_skip_scan_indexesIdentifies composite B-tree indexes with low-NDV leading columns suitable for PostgreSQL 19 skip-scan, flagging trailing column indexes for potential removal.
Instructions
Find composite B-tree indexes whose leading column has low NDV — these are the ones PG 19's skip-scan optimisation unlocks. Each candidate's trailing columns can now be served by the composite index alone, so any dedicated single-column indexes on those trailing columns become review candidates for recommend_index_drops. Returns an empty list on PG ≤ 18 or driver failure — pair with get_skip_scan_status for the diagnostic. max_leading_ndv (default 1000) caps the leading-column NDV that's considered low enough for skip-scan to be profitable. Returns a list of objects with schema, table, index_name, leading_column, trailing_columns (list of strings), estimated_leading_ndv (int), and rationale (human-readable explanation).
Example: recommend_skip_scan_indexes()
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | No | Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids. | |
| max_leading_ndv | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |