get_table_stats
Analyze PostgreSQL table statistics to identify maintenance needs and performance issues. Get table sizes, row counts, scan ratios, and vacuum history to optimize database performance.
Instructions
Get detailed statistics for database tables.
Returns information about:
Table size (data, indexes, total)
Row counts and dead tuple ratio
Last vacuum and analyze times
Sequential vs index scan ratios
Cache hit ratios
This helps identify tables that may need maintenance (VACUUM, ANALYZE) or have performance issues.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| schema_name | No | Schema to analyze (default: public) | public |
| table_name | No | Specific table to analyze (optional, analyzes all tables if not provided) | |
| include_indexes | No | Include index statistics | |
| order_by | No | Order results by this metric | size |
Input Schema (JSON Schema)
{
"properties": {
"include_indexes": {
"default": true,
"description": "Include index statistics",
"type": "boolean"
},
"order_by": {
"default": "size",
"description": "Order results by this metric",
"enum": [
"size",
"rows",
"dead_tuples",
"seq_scans",
"last_vacuum"
],
"type": "string"
},
"schema_name": {
"default": "public",
"description": "Schema to analyze (default: public)",
"type": "string"
},
"table_name": {
"description": "Specific table to analyze (optional, analyzes all tables if not provided)",
"type": "string"
}
},
"required": [],
"type": "object"
}