Index statistics
pg_index_statsInspect PostgreSQL index size, scans and definitions, then flag unused, duplicate, redundant or invalid indexes to safely identify which ones to drop.
Instructions
List indexes with size, scans, tuples read and fetched, unique/primary/valid flags,
access method and definition, and find the ones to drop: show="unused" (never scanned
and not backing a constraint), "duplicate" (same columns, operator classes and
predicate as another index), "redundant" (columns are the leading columns of a longer
index) or "invalid" (a failed CREATE INDEX CONCURRENTLY).
Filter with schema and table (name, schema.name or a pattern with *). "Unused"
counts scans since the statistics reset (counters_since) on this server only: an index
used just on a replica or by a rare job looks unused here, so check before dropping.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "pg_index_stats"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| show | No | all | |
| limit | No | ||
| table | No | ||
| schema | No | ||
| connection | No |