Parameter · Vacuuming / Automatic Vacuuming
autovacuum_naptime
Time to sleep between autovacuum runs.
- Default:
1min - Type: integer (s)
- Range: 1s … 2147483s
- Applies: Reload
In plain words
The autovacuum launcher sleeps between rounds. Within each autovacuum_naptime it tries to visit every database once and start a worker there, which then checks which tables need cleaning.
Shorter means tables over their threshold get noticed sooner; longer means less checking but slower reaction.
For DBAs and operators
The naptime is spread across databases: with N databases, the launcher tries to start a worker roughly every naptime / N, so each database is visited about once per naptime. A worker scans pg_class and the statistics for its database, builds the list of tables over threshold, and processes them one by one. It is not a "run vacuum every minute" timer: if no table qualifies, nothing is vacuumed.
Tuning
- The default 1 min is fine for most systems. Busy OLTP queue tables that bloat within seconds are better handled by lower per-table thresholds than by a tiny naptime.
- Clusters with hundreds of databases: each visit costs a little catalog work; a very small naptime with many databases mostly burns CPU in workers that find nothing to do.
- If every worker is busy for hours on huge tables, a short naptime does not help: the real limit is autovacuum_max_workers and the cost limit.
Observe
SELECT relname, last_autovacuum, last_autoanalyze
FROM pg_stat_user_tables ORDER BY last_autovacuum NULLS FIRST;How to change it
Change in postgresql.conf or ALTER SYSTEM, then run SELECT pg_reload_conf().
See it in context
Autovacuum launcher and workers Autovacuum: when tables get vacuumed
Related parameters
autovacuum autovacuum_max_workers autovacuum_vacuum_threshold