get_table_bloat_analysis
Analyze PostgreSQL table bloat by calculating dead tuple ratios, estimating bloat size, and identifying tables requiring VACUUM maintenance to optimize storage and performance.
Instructions
[Tool Purpose]: Analyze table bloat based on dead tuple statistics and size information
[Exact Functionality]:
Calculate bloat ratio based on dead tuples vs total tuples
Estimate bloat size in bytes and human-readable format
Show last VACUUM/AUTOVACUUM timestamps for maintenance tracking
Identify tables requiring VACUUM maintenance
Filter tables by name pattern using SQL LIKE or ILIKE matching
Sort results by bloat severity (dead tuple ratio and count)
[Required Use Cases]:
When user requests "table bloat", "bloat analysis", "dead tuples", etc.
When identifying tables that need VACUUM maintenance
When investigating database storage efficiency and space usage
When troubleshooting performance issues related to table bloat
When analyzing specific table groups (e.g., tables with "user", "log", "temp" in names)
[Strictly Prohibited Use Cases]:
Requests for automatic VACUUM execution
Requests for bloat removal or cleanup operations
Requests for table restructuring or data modification
Args: database_name: Target database name (uses default database from POSTGRES_DB env var if omitted) schema_name: Schema to analyze (analyzes all user schemas if omitted) table_pattern: Table name pattern to filter (SQL LIKE pattern, e.g., 'user%', '%log%', 'temp_*') min_dead_tuples: Minimum dead tuples to include in results (default: 1, shows all tables with any bloat) limit: Maximum number of results to return (1-100, default: 20)
Returns: Table bloat analysis with bloat ratios, sizes, and maintenance recommendations
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database_name | No | ||
| schema_name | No | ||
| table_pattern | No | ||
| min_dead_tuples | No | ||
| limit | No |