DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · Write-Ahead Log / Settings

wal_buffers

Sets the number of disk-page buffers in shared memory for WAL. -1 means use a fraction of "shared_buffers".

  • Default: -1
  • Type: integer (8kB)
  • Range: -1 … 2097144kB
  • Applies: Restart required

In plain words

Before WAL goes to disk it is collected in a small shared memory area, the WAL buffers. If they fill up before the WAL writer or a committing session writes them out, a session has to stop and write WAL itself.

The default (-1) sizes it automatically from shared_buffers, up to 16 MB, which is right for almost every system.

For DBAs and operators

-1 picks 1/32 of shared_buffers, at least 64 kB and at most one WAL segment (16 MB): with the default 128 MB of shared buffers that is 4 MB (SHOW wal_buffers shows 4MB). Any shared_buffers of 512 MB or more gives the 16 MB cap. Manual values below 32 kB are raised to 32 kB.

WAL is written out at every commit, by the WAL writer every wal_writer_delay, and whenever a backend needs a buffer page that still holds unwritten WAL. That last case is a stall:

SELECT wal_buffers_full, wal_records, stats_reset FROM pg_stat_wal;

A wal_buffers_full counter that grows quickly during bulk loads or many concurrent writers is the signal to raise it, e.g. to 32–64 MB on very busy servers. Because WAL buffers are written out at every commit, much larger values rarely bring a significant benefit. Requires a restart.

How to change it

Change in postgresql.conf or ALTER SYSTEM, then restart the server.

See it in context

Write-ahead log (WAL) WAL writer Memory architecture Shared buffers The big picture

Related parameters

shared_buffers wal_writer_delay wal_writer_flush_after synchronous_commit

All Write-Ahead Log parameters