index_analyzer
index_analyzer · PL/pgSQL functions for evaluating existing and prospective indexes and checking foreign-key indexing.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100475 | index_analyzer | index_analyzer | 0.1.0 | FEAT | BSD-2-Clause | SQL |
| Relationships | |
|---|---|
| Requires | plpgsql |
Usage
Sources:
index_analyzer is a set of PL/pgSQL diagnostics for examining existing indexes and detecting foreign keys without a matching index on the referencing table. Its findings are leads for investigation, not automatic drop or create decisions.
Core Workflow
Run the broad checks for a schema, then inspect individual tables or indexes with a selectivity threshold expressed as a fraction.
The functions report findings with notices rather than returning a recommendations table. Capture client messages when running them in automation.
Function Index
analyze_tables,analyze_table, andanalyze_indexcoordinate checks over user tables and indexes.analyze_index_selectivityestimates distinct-value selectivity from catalog statistics.analyze_index_usagecompares index and sequential-scan statistics and skips unique indexes, including primary keys.analyze_index_count_distinctsamples table data for a distinct-count estimate.analyze_fksandanalyze_fkinspect foreign-key indexing by schema, table OID, constraint name, or constraint OID.
Interpretation and Caveats
The upstream explicitly warns that answers are not definitive. Usage counters depend on workload history, catalog estimates can overstate selectivity for correlated columns, and the sampling check can be expensive and is weak for expression indexes. Only user tables are considered.
The repository is archived. Its control file declares version 0.1.0, while the checked-in install script is named index_analyzer--0.0.1.sql; verify that the packaged artifact resolves this upstream mismatch before installation. Review every suggested index against constraints, rare critical queries, and a representative observation window.