DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · Resource Usage / Memory

vacuum_buffer_usage_limit

Sets the buffer pool size for VACUUM, ANALYZE, and autovacuum.

  • Default: 2MB
  • Type: integer (kB)
  • Range: 0 … 16GB
  • Applies: Session (any user)

In plain words

VACUUM reads whole tables. If it used shared buffers like a normal query, it would push everyone else's hot data out. So it reuses a small private set of buffers, a ring, over and over. This setting is the size of that ring. Bigger rings make VACUUM faster but evict more useful pages; 0 lets VACUUM use the whole cache.

For DBAs and operators

Added in PostgreSQL 16 (default 256 kB), default raised to 2 MB in PostgreSQL 17. Valid values are 0 or 128 kB – 16 GB, silently capped at 1/8 of shared_buffers. Applies to VACUUM, ANALYZE and autovacuum; override per command with VACUUM (BUFFER_USAGE_LIMIT '512MB') tbl.

A small ring has a hidden cost: when the ring wraps around to a buffer VACUUM dirtied, the WAL for it must be flushed and the page written before the buffer can be reused, so VACUUM ends up doing many small WAL flushes and writes itself. A larger ring (e.g. 16–256 MB) lets bgwriter/checkpointer handle more of that.

-- ring activity shows up in pg_stat_io with context 'vacuum'
SELECT backend_type, reads, writes, reuses, evictions
  FROM pg_stat_io WHERE context = 'vacuum';

When the failsafe triggers (vacuum_failsafe_age) the ring is abandoned and VACUUM may use all of shared buffers. A one-off VACUUM (BUFFER_USAGE_LIMIT 0) during a maintenance window is a good way to speed up a big catch-up vacuum.

How to change it

Any user can change it for their session with SET.

See it in context

VACUUM Shared buffers Buffer manager internals HOT updates

Related parameters

shared_buffers vacuum_cost_limit vacuum_failsafe_age maintenance_work_mem

All Resource Usage parameters