Databases Intermediate By Samson Tanimawo, PhD Published Oct 23, 2026 9 min read

Vacuum Tuning in Postgres: A Deep Dive

Postgres vacuum is the source of countless ‘our database got slow’ incidents. The tuning is mechanical when you understand the four settings.

Why vacuum matters

Postgres MVCC: dead tuples accumulate; vacuum reclaims them; without it, tables bloat and queries slow.

Default autovacuum is conservative; large/active tables need tuning.

Four key settings

Per-table overrides

Per-table: ALTER TABLE x SET (autovacuum_vacuum_scale_factor = 0.05) for hot tables.

Default 0.2 = vacuum when 20% dead; for hot tables, 0.05 keeps bloat down.

Symptoms of bad tuning

Bloat increasing; query planner stats stale; long autovacuum runs that never complete.

Each is a tuning signal; address before they become incidents.

Antipatterns

What to do this week

Three moves. (1) Apply this pattern to your most-loaded table. (2) Measure query latency / write throughput before/after. (3) Document the win and the constraint so the next refactor inherits the knowledge.