# vacuum_cost_delay

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

Source: https://sqlly.app/sql-configuration/postgresql/vacuum-cost-delay
Last updated: 2026-11-30
License: Text and data [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) (credit SQLly, sqlly.app); code and SQL snippets [MIT](https://opensource.org/license/mit). [Details](https://sqlly.app/license).

**Default**

`0 (unthrottled)`

**Range**

0 to 100ms

**Restart needed**

No

**Default checked on**

PostgreSQL 18

## What it does

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.

## Default value

`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](https://sqlly.app/sql-configuration/postgresql), or check the [PostgreSQL manual](https://www.postgresql.org/docs/current/runtime-config.html) for every option.

## Related PostgreSQL settings

- [`autovacuum_vacuum_cost_limit` I/O budget autovacuum spends before sleeping for autovacuum_vacuum_cost_delay; -1 uses vacuum_cost_limit.](https://sqlly.app/sql-configuration/postgresql/autovacuum-vacuum-cost-limit)
- [`autovacuum_max_workers` How many autovacuum workers can run at the same time.](https://sqlly.app/sql-configuration/postgresql/autovacuum-max-workers)
- [`maintenance_work_mem` Memory for VACUUM, CREATE INDEX, ALTER TABLE ADD FOREIGN KEY and similar maintenance.](https://sqlly.app/sql-configuration/postgresql/maintenance-work-mem)

## Related on SQLly

- [When a fast query turns slow Performance guide](https://sqlly.app/sql-performance/sudden-slowdown)
- [PostgreSQL query performance troubleshooting Performance guide](https://sqlly.app/sql-performance/postgresql)
