feat(cli): implement F004 and F005 bloat estimation checks
Summary
Implement heap and index bloat estimation for express mode checkup.
New Checks
F004 - Autovacuum: heap bloat estimate
- Estimates table bloat using pg_stats column statistics
- Returns top 100 tables by bloat size (>= 1 MiB)
- Shows real size, extra size, bloat percentage, fillfactor
F005 - Autovacuum: index bloat estimate
- Estimates B-tree index bloat using pg_stats
- Returns top 100 indexes by bloat size (>= 1 MiB)
- Shows real size, table size, bloat percentage, fillfactor
Implementation Notes
- Uses standard
pg_statsview (no special extensions required) - Based on well-known bloat estimation algorithms
- Excludes system schemas (pg_catalog, information_schema, pg_toast)
- Minimum size threshold of 1 MiB to focus on meaningful bloat
Related
- MR: !180 (merged)
Acceptance Criteria
- F004 (heap bloat estimate) uses
pg_statscolumn statistics to estimate table bloat without requiring special extensions - F005 (index bloat estimate) estimates B-tree index bloat using
pg_stats - Both reports return the top 100 objects sorted by bloat size with a minimum threshold of 1 MiB
- Reports include: real size, extra size (estimated bloat), bloat percentage, and fillfactor for each object
- System schemas (pg_catalog, information_schema, pg_toast) are excluded from results
Definition of Done
- MR !180 (merged) merged
- Bloat estimates validated against known bloated tables (compare with
pgstattupleextension results if available) - Reports work across PostgreSQL 13-17
- JSON output follows existing checkup report conventions
Edited by Nikolay Samokhvalov