Postgres Vacuum vs Autovacuum
Tuning vacuum.
Overview
Postgres autovacuum runs by default; that does not make it tuned. The discipline is recognising when default autovacuum suffices, when per-table tuning is required, and when explicit manual vacuum is the right move.
- Autovacuum default. Postgres runs autovacuum on its own schedule. Sufficient for low-write tables.
- Per-table tuning. High-write tables need aggressive autovacuum settings. The defaults are too lazy under heavy write load.
- Manual vacuum. Before bulk operations or after large batch updates. Autovacuum will not run on the timeline a bulk operation needs.
- VACUUM ANALYZE. Updates planner statistics in addition to reclaiming space. Run after large data changes for accurate query plans.
The approach
Three habits keep Postgres vacuum healthy: per-table tuning for the high-write tables, continuous bloat monitoring, and manual vacuum at known stress points.
- Per-table tuning.
autovacuum_vacuum_scale_factorat 0.05 or lower for write-heavy tables. The defaults are too generous. - Monitor bloat. Per-table dead-tuple percentage on the database dashboard. Alert at 20 percent for high-traffic tables.
- Manual vacuum at known points. Before bulk inserts or after large update batches.
VACUUM (ANALYZE)updates statistics at the same time. - Monthly ANALYZE plus documented strategy. Manual ANALYZE monthly catches statistics drift; per-table strategy lives in the runbook.
Why this compounds
Each tuned table produces ongoing query-performance benefit. Patterns transfer across Postgres deployments; new tables ship with the right settings instead of the global defaults.
- Faster queries. Less bloat means more index-scans where index-scans should happen. p99 query time benefits.
- Storage efficiency. Less bloat means less storage. The savings continue every month.
- Stability. Aggressive autovacuum prevents transaction-wraparound emergencies that show up as full-database freezes.
- Year-one investment, year-two habit. The first tuning is heavy lift. By the third table, the team knows the knobs and the right values reflexively.