// postgresql · vacuum, statistics & maintenance

vacuum_cost_delay

How long VACUUM sleeps each time it exhausts its I/O cost budget; 0 runs unthrottled.

Par défaut
0 (unthrottled)
Range
0 to 100ms
Restart needed
Non
Default checked on
PostgreSQL 18

Ce que cela fait

Cost-based vacuum spreads a manual VACUUM's writes over time instead of taking all the bandwidth it can, one budget of vacuum_cost_limit (200) per process. Autovacuum keeps its own delay, autovacuum_vacuum_cost_delay (2ms), unless that is set to -1 to inherit this value.

Valeur par défaut

0 (unthrottled). 0 (PostgreSQL 18); the default has been 0 since PostgreSQL 12 (it was 20ms).

Check the current value

SHOW vacuum_cost_delay;

SELECT setting, unit, boot_val, context, source, pending_restart
FROM pg_settings
WHERE name = 'vacuum_cost_delay';

Change it

SET vacuum_cost_delay = '2ms';   -- this session
ALTER ROLE reporting SET vacuum_cost_delay = '2ms';   -- new sessions of one role

ALTER SYSTEM SET vacuum_cost_delay = '2ms';
SELECT pg_reload_conf();

No restart. Any role can SET it for a session or with SET LOCAL for one transaction; a server-wide ALTER SYSTEM change applies after a reload (context is user).

When to change it

SET it in the session running a deliberate VACUUM on a busy server during business hours; 1-2ms is usually enough to keep VACUUM from dominating the disk.

What can go wrong

A few milliseconds of delay per cost budget caps VACUUM far below what the disk can do, so a vacuum that would finish in minutes can take hours. Operations holding critical locks skip the delay, so the throttle never becomes a hard bound on vacuum progress.

Questions about vacuum_cost_delay

What is the default value of vacuum_cost_delay in PostgreSQL?

0 (unthrottled). 0 (PostgreSQL 18); the default has been 0 since PostgreSQL 12 (it was 20ms).

Does changing vacuum_cost_delay require a restart?

No. No restart. Any role can SET it for a session or with SET LOCAL for one transaction; a server-wide ALTER SYSTEM change applies after a reload (context is user).

When should I change vacuum_cost_delay?

SET it in the session running a deliberate VACUUM on a busy server during business hours; 1-2ms is usually enough to keep VACUUM from dominating the disk.

Back to all PostgreSQL settings, or check the PostgreSQL manual for every option.

// one client for every engine

Check vacuum_cost_delay on your own server

SQLly runs the query above against PostgreSQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.

Texte et données de cette page : CC BY 4.0, en citant SQLly (sqlly.app). Code et extraits SQL : MIT. Détails de la licence