Parameter · Vacuuming / Cost-Based Vacuum Delay
vacuum_cost_delay
Vacuum cost delay in milliseconds.
- Default:
0 - Type: real (ms)
- Range: 0 … 100ms
- Applies: Session (any user)
In plain words
VACUUM can throttle itself so it does not hog the disk: it counts "cost points" for each page it touches and, after vacuum_cost_limit points, sleeps for this long. For manual VACUUM the default 0 means no throttling at all.
For DBAs and operators
Applies to manual VACUUM/ANALYZE and, when autovacuum_vacuum_cost_delay = -1, to autovacuum. Values below 1 ms are allowed (microsecond sleeps). The sleep is actually delay × balance / limit, capped at 4 × delay, so when the balance overshoots (no sleep is taken while vacuum holds certain locks) the nap is longer.
Rough throughput ceiling: limit / delay points per ms. With limit 200 and 2 ms that is 100,000 points/s: about 800 MB/s of cached pages, 400 MB/s of reads, or 40 MB/s of dirtied pages.
SET vacuum_cost_delay = '2ms';
VACUUM (VERBOSE) big_table; -- throttled manual vacuum
-- PG18: time spent sleeping
SET track_cost_delay_timing = on;
SELECT pid, relid::regclass, delay_time FROM pg_stat_progress_vacuum;Remember the failsafe ignores the delay.
In this model the slider starts at 0.5 ms: at the default 0 a manual VACUUM never sleeps.
How to change it
Any user can change it for their session with SET.
See it in context
VACUUM Autovacuum: when tables get vacuumed ANALYZE and statistics
Related parameters
vacuum_cost_limit autovacuum_vacuum_cost_delay vacuum_cost_page_dirty track_cost_delay_timing