Junior — Middle
What is the standard lifetime of a WAL in PostgreSQL?
sobes.tech AI
Answer from AI
In PostgreSQL, WAL (Write-Ahead Logging) is divided into fixed-size segments, usually 16 MB each. The standard lifetime of a WAL segment is not fixed in time but depends on database activity and settings.
WAL segments are stored until they are needed for recovery or replication. After that, they can be deleted or archived.
The main parameters affecting the lifetime of WAL:
wal_keep_segments— the number of segments to keep for replication.archive_modeandarchive_command— if archiving is enabled, segments are stored outside the database.
Thus, the lifetime of a WAL segment is determined by load and settings, not by a fixed time value.