Parameter · Preset Options
wal_segment_size
Shows the size of write ahead log segments.
- Default:
16MB - Type: integer (B)
- Range: 1MB … 1GB
- Applies: Read-only
In plain words
The write-ahead log is split into files of equal size, 16 MB by default. When one is full, PostgreSQL moves on to the next. Archiving, replication and point-in-time recovery all work with these files.
For DBAs and operators
Since PostgreSQL 11 it is chosen at initdb --wal-segsize=N (MB, power of two, 1–1024) and can be changed later only with the server stopped using pg_resetwal --wal-segsize (rarely advisable). Shown in bytes.
File names
TTTTTTTTXXXXXXXXYYYYYYYY: timeline, then the WAL position split into "log id" and segment number. With 16 MB segments there are 256 segments per log id, so names go …000000FF → 000000010000000100000000. With other sizes the pattern differs, which confuses scripts that compute names by hand; use pg_walfile_name(pg_current_wal_lsn()).
Why change it
- Very high WAL rates (hundreds of MB/s): 64–256 MB segments mean fewer files, fewer
archive_commandcalls and less per-file overhead. min_wal_size/max_wal_sizemust be at least two segments.archive_timeoutforces a switch to a new segment, and each forced switch still produces a full-size file (compressible).
How to change it
Fixed when PostgreSQL was built or the cluster was initialised. You can only read it.
See it in context
Write-ahead log (WAL) Archiving and point-in-time recovery Physical layout on disk