Parameter · Vacuuming / Automatic Vacuuming
autovacuum
Starts the autovacuum subprocess.
- Default:
on - Type: bool
- Applies: Reload
In plain words
Autovacuum is the built-in cleaner: a launcher process watches table activity and starts workers that remove dead row versions, refresh planner statistics and freeze old rows. Turning it off does not stop rows from dying; it only stops the cleaning, so tables bloat and statistics go stale.
Even when it is off, PostgreSQL still starts workers when a table gets close to transaction ID wraparound, because that is a safety issue.
For DBAs and operators
The launcher runs permanently only when autovacuum = on and track_counts = on: the decisions are made from the counters in pg_stat_user_tables. With it off, anti-wraparound vacuums (triggered by autovacuum_freeze_max_age) are still launched, which surprises people who "disabled autovacuum" and still see autovacuum: VACUUM public.big (to prevent wraparound) in pg_stat_activity.query.
Better than turning it off
- Disable per table only where you really vacuum yourself:
ALTER TABLE staging SET (autovacuum_enabled = false);(andtoast.autovacuum_enabled). - Make it gentler or more aggressive with the cost settings and per-table thresholds instead.
- If it "blocks" your DDL: autovacuum cancels itself when another session waits for a conflicting lock (ERROR: canceling autovacuum task), except for anti-wraparound runs, which do not yield.
Observe
SELECT pid, query, wait_event_type, wait_event, xact_start
FROM pg_stat_activity WHERE backend_type IN ('autovacuum launcher','autovacuum worker');
SELECT relname, n_live_tup, n_dead_tup, n_mod_since_analyze, n_ins_since_vacuum,
last_autovacuum, last_autoanalyze, autovacuum_count
FROM pg_stat_user_tables ORDER BY n_dead_tup DESC LIMIT 20;Log every run with log_autovacuum_min_duration = 0 (default 10 min) to see lines such as LOG: automatic vacuum of table "app.public.orders": index scans: 1 followed by pages, tuples, frozen and buffer-usage details.
How to change it
Change in postgresql.conf or ALTER SYSTEM, then run SELECT pg_reload_conf().
See it in context
Autovacuum: when tables get vacuumed Autovacuum launcher and workers VACUUM The big picture Life of a DELETE HOT updates
Related parameters
track_counts autovacuum_naptime autovacuum_max_workers log_autovacuum_min_duration autovacuum_freeze_max_age