Capacity Planning and Bloat Audits
Forecast disk and IOPS growth, audit table and index bloat regularly, and plan upgrades before you run out.
What to Forecast
To size your database for the next 6–12 months you need to project:
- Disk usage (data + WAL + indexes)
- IOPS demand
- RAM working set
- Connection count
Disk Growth
Trend recent growth:
SELECT pg_size_pretty(pg_database_size(current_database()));
SELECT pg_size_pretty(pg_total_relation_size(t.oid)) AS total,
relname
FROM pg_class t
WHERE relkind = 'r'
ORDER BY pg_total_relation_size(t.oid) DESC LIMIT 20;All lessons in this course
- pg_stat_statements: Top Queries
- pgBadger for Log Analysis
- Connection Pooling: PgBouncer
- Capacity Planning and Bloat Audits