Get Table Statistics
pg_table_statsGet detailed table statistics like size, live and dead rows, vacuum and analyze dates, and scan counts to detect bloated tables, missing vacuums, or underused indexes.
Instructions
Get detailed statistics for tables: size, live/dead rows, vacuum/analyze info, scan counts.
Useful for identifying bloated tables, missing vacuums, or underused indexes.
Args:
schema: Filter to a specific schema (optional, shows all user schemas if omitted)
table: Filter to a specific table name (optional)
response_format: Output format
Returns: JSON: { stats: TableStats[], count: number } Markdown: formatted table with size, rows, vacuum dates, scan counts
Note: Requires pg_stat_user_tables access. Row counts are from pg_stat_user_tables (updated by autovacuum/analyze) — use pg_count_rows for exact counts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| schema | No | Filter to specific schema (optional) | |
| table | No | Filter to specific table (optional) | |
| response_format | No | Output format: 'markdown' for human-readable, 'json' for machine-readable | markdown |