Table and index bloat
pg_bloatEstimate table and btree index bloat from planner statistics, rank relations by wasted bytes without scanning, or measure a specific table with pgstattuple for exact density.
Instructions
Estimate how much space tables and btree indexes waste (bloat) and rank them by wasted bytes, without scanning anything: the estimate comes from the row counts and average row widths in the planner statistics and is usually within 10 to 20 percent.
kind is tables, indexes or both; schema narrows the search; min_wasted_bytes hides
small waste. Relations never analyzed are skipped (run ANALYZE). For a measurement
instead of an estimate pass exact_table (name or schema.name): it reads that table
with the pgstattuple extension (pgstattuple_approx when available) and also reports the
density of its btree indexes, at the cost of reading the relation.
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_bloat"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kind | No | both | |
| limit | No | ||
| schema | No | ||
| connection | No | ||
| exact_table | No | ||
| min_wasted_bytes | No |