Overview
This page is the atomic definition. Postgres internals live at postgres.
Definition
The write-ahead log (WAL) is a sequential, append-only record of every change made to a database. Before applying any change to data files, the database writes a WAL record describing the change and flushes it to disk. On crash recovery, the database replays WAL records to reconstruct the committed state. This provides the Durability guarantee in acid. In PostgreSQL, WAL also powers logical and physical read-replica replication: standbys stream WAL records from the primary and apply them to stay in sync. WAL is also the foundation for Change Data Capture (CDC): tools like Debezium, PgLogical, and Supabase Realtime subscribe to the WAL stream and emit change events to downstream systems (message queues, search indexes, caches). SQLite also uses WAL mode as an alternative journal mode that improves concurrent read performance.
When it applies
WAL is always active in PostgreSQL; no configuration is needed for crash safety. Enable WAL-level replication (wal_level = logical or replica) to use read replicas or CDC. In SQLite, enable WAL mode with PRAGMA journal_mode=WAL for workloads with concurrent readers.
Example
-- Inspect recent WAL activity in Postgres:
SELECT * FROM pg_walfile_name(pg_current_wal_lsn());Related concepts
- postgres - Postgres WAL configuration (
wal_level,max_wal_size). - acid - WAL provides the Durability property.
- read-replica - replicas receive and apply the WAL stream.
- sqlite - SQLite WAL mode improves concurrent read throughput.
Citing this term
See Write-ahead log (llmbestpractices.com/glossary/write-ahead-log).