Analyze Index Usage Statistics
pg_index_usageIdentify unused or underused PostgreSQL indexes by analyzing scan counts and tuple statistics to remove storage waste and improve write performance.
Instructions
Show index scan counts and tuple statistics to identify unused or underused indexes.
Indexes with 0 scans that are not primary keys waste storage and slow writes — candidates for removal.
Args:
schema: Filter to a specific schema (optional)
min_table_size_mb: Only show indexes on tables larger than N MB (default: 0)
show_unused_only: Only show indexes with 0 scans (default: false)
response_format: Output format
Returns: JSON: { indexes: IndexUsage[], count: number } Markdown: table sorted by scan count ascending (least used first)
Note: Statistics reset on pg_stat_reset() or server restart. Low scans on a new server may not mean unused.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| schema | No | Filter to schema (optional) | |
| min_table_size_mb | No | Minimum table size in MB to include | |
| show_unused_only | No | Only show indexes with 0 scans | |
| response_format | No | Output format: 'markdown' for human-readable, 'json' for machine-readable | markdown |