Auto-vacuum Tuning

Postgres-specific.

Why auto-vacuum tuning matters

Postgres needs to reclaim dead tuples to keep tables and indexes healthy. The defaults are conservative on purpose; production write-heavy workloads usually need more aggressive tuning to avoid the bloat that produces slow queries, oversized indexes, and eventual full-table rewrites.

The key parameters

Three parameters are the main levers: scale-factor, threshold, and max-workers. Each tunes a different aspect of when and how aggressively autovacuum runs.

Per-table tuning

Per-table tuning is the surgical layer. Hot tables get aggressive overrides; cold tables stay on defaults; one autovacuum policy across thousands of tables wastes either I/O or freshness.

Monitoring vacuum activity

Monitoring closes the loop. Vacuum stats, bloat estimation, and in-flight progress together tell you whether tuning is keeping up with the write rate.

Emergency interventions

Emergency interventions are the last resort when tuning has fallen behind reality. VACUUM FREEZE, VACUUM FULL, and pg_repack each suit different blast radii.