Autovacuum is PostgreSQL’s background process that cleans up dead tuples created by MVCC and refreshes statistics, so tables don’t bloat and the optimizer stays accurate.
Why it exists (one line)
Postgres uses MVCC, so updates/deletes create dead rows; autovacuum removes them and updates stats automatically.
What AutoVacuum does
- VACUUM: removes dead tuples, frees space for reuse
- ANALYZE: updates table/column statistics for the optimizer
- Prevents transaction ID wraparound (critical safety task)
When it runs
Autovacuum triggers per table when changes exceed thresholds:
autovacuum_vacuum_threshold + autovacuum_vacuum_scale_factor * table_sizeautovacuum_analyze_threshold + autovacuum_analyze_scale_factor * table_size
(Defaults work for many cases; hot tables often need tuning.)
Why backend engineers care
- Disabled/misconfigured autovacuum ⇒ table bloat, slow queries
- Stale stats ⇒ bad plans (wrong joins/scans)
- OLTP systems rely on it for steady performance
Interview-ready sentence
Autovacuum is PostgreSQL’s background worker that reclaims space from dead rows and keeps optimizer statistics fresh to maintain performance and prevent bloat.