VIEW THIS AS

Auto mode follows the Route Engine until you choose a viewpoint.

YOU ARE HERE

ROUTE CHECK

CONNECTED TO

WHAT NEXT

Use the canonical route for this room, or HELP if you are unsure.

How Write-Ahead Logging Works in Databases | WAL Records, Durable Commit, Checkpoints and Crash Recovery

Three secondary students review open books and notes together in a classroom.

Write-ahead logging works by recording enough information about a database change in a durable log before the database is allowed to depend on a later write of the corresponding data page. The central ordering rule is simple: the log goes first; the data page can follow.

That ordering changes the cost of transactions. A database does not need to force every modified table and index page to durable storage at each commit. It can flush a compact sequential log record first, acknowledge the transaction under the configured durability contract, and write dirty data pages later in larger batches. If the server crashes before those pages reach storage, recovery can replay the log.

This master guide explains WAL records, log sequence positions, dirty pages, durable commit, group commit, asynchronous commit, checkpoints, crash recovery, redo, full-page protection, WAL retention, replication, archival recovery, backups, performance trade-offs and the difference between a transaction being logically committed and every affected data page already being physically rewritten.

Foundation: How Databases Work · Related: How MVCC Works · Related: How LSM Trees Work · How X Works Hub

Pillar Explainers for This Master Guide

Read the master first for the one non-negotiable invariant—log before data—then use the pillars to follow the three places where that invariant becomes operational: building a durable baseline, sharing commit flushes and reconstructing state after failure.

The cluster deliberately separates three maintenance questions from the WAL invariant itself: when dirty data becomes a trusted baseline, how concurrent commits share durable synchronization, and how restart reconciles surviving pages with the durable log.


The Direct Answer: Why the Log Must Go First

The Data Page May Still Be in Memory

Suppose a transaction changes a balance, inserts an index entry and updates a row header. Those modifications can exist in database memory while the corresponding on-disk pages still contain the older state. Forcing every touched page at commit would create random writes across many files and make small transactions expensive.

The Log Provides a Recoverable Promise

WAL records describe enough of those changes to reproduce the required durable state later. Once the relevant log records and commit information have reached the durability boundary required by the transaction, the database can postpone page flushing. PostgreSQL’s current WAL introduction states the core rule directly: data-file changes must be logged and the WAL flushed before those data changes are written to permanent storage.


The Rule Is About Ordering, Not Merely About Having a Log

A Diagnostic Log Is Not WAL

An application can print every SQL statement to a text file and still have no usable crash-recovery protocol. Recovery needs records with defined ordering, page or object identity, transaction semantics and a durable publication rule.

The Critical Invariant Is Log Before Data

If a dirty page reaches durable storage containing a change whose corresponding WAL record has not reached the required durable point, a crash can leave the data file ahead of the recovery history. That violates the write-ahead rule. Buffer managers and page writers therefore coordinate with the WAL position associated with each dirty page.


WAL Records Describe Low-Level Changes

Logical SQL Is Usually Not the Recovery Unit

The engine does not normally recover by rerunning the original UPDATE text. Recovery records describe lower-level effects appropriate to the storage engine: page changes, transaction status records, relation operations and other internal actions.

One SQL Statement Can Produce Many WAL Records

Updating one indexed row may modify a heap page, one or more index pages and transaction metadata. Those changes can produce several records. Conversely, one WAL record can describe a compact operation whose replay changes a page deterministically.


Log Sequence Positions Create a Total Recovery Order

Every Record Occupies a Position

Many WAL systems identify records by a monotonically advancing location, commonly called a log sequence number or equivalent position. PostgreSQL uses LSNs to identify positions in the WAL stream.

Pages Can Remember How Far They Have Been Updated

A page header can store the WAL position of the latest change reflected in that page. During redo, the engine can compare the page’s state with the log record and avoid applying a change that the page already contains. Exact mechanics vary by engine, but position-aware replay is central to idempotent recovery designs.


Dirty Pages Are Modified Pages Not Yet Fully Persisted

Memory Can Lead Storage

A page loaded into the buffer pool is changed by a transaction. The buffer copy now differs from the durable copy on disk, so it is dirty.

Dirty Does Not Mean Uncommitted

A dirty page can contain changes from committed transactions, uncommitted transactions, or a mixture depending on the engine’s page format and concurrency model. WAL durability and transaction visibility decide whether logical work is committed; dirty-page status tells the buffer manager whether the current page image still needs writing.


Commit and Page Flush Are Different Events

A Transaction Can Commit Before Its Data Pages Are Written

This is one of WAL’s major performance advantages. The commit record and preceding required WAL can be made durable through a sequential log flush while modified data pages remain in memory.

Recovery Bridges the Gap

If the machine crashes before those pages reach disk, the restart procedure replays WAL records after an appropriate checkpoint or redo position. PostgreSQL’s WAL documentation describes this as roll-forward or REDO recovery.


Durability Depends on the Acknowledgement Contract

Synchronous Commit Waits for a Defined Durable Point

A database can delay the client response until the local WAL record is flushed to durable storage, or under synchronous replication until additional remote conditions are satisfied.

Asynchronous Commit Changes What Success Means

PostgreSQL documents a mode in which success can be reported before the commit record is durably flushed locally. A crash can then lose some recently acknowledged transactions without corrupting the database’s internal consistency. That is a durability trade, not the same as disabling all WAL safety.


The Commit Record Is a Visibility Boundary

Data Changes Can Exist Before Commit

A transaction can generate WAL for row and index changes while it is still in progress.

Commit Makes the Transaction Durable Under the Chosen Mode

The recovery system must distinguish transactions whose commit decision became durable from work that never committed. Different engines represent this differently, but the key question is whether replayed physical changes belong to a committed logical outcome or must remain invisible or be undone by that engine’s recovery model.


Group Commit Shares One Expensive Flush

Several Transactions Can Reach Commit Together

If each transaction forced its own storage synchronization, the device might spend much of its time on repeated latency rather than useful bytes.

One WAL Flush Can Satisfy Many Committers

PostgreSQL’s WAL documentation notes that concurrent transactions can be committed by one WAL fsync. Its current configuration documentation describes group-commit behaviour and an optional commit_delay that can briefly wait for more followers before the leader flushes.


Group Commit Trades a Little Waiting for Shared Work

Throughput Can Improve When Flush Latency Is Significant

If five transactions need durability within the same small window, one physical flush can cover all WAL positions up to the highest required position.

Too Much Artificial Delay Can Hurt

Waiting deliberately is useful only if enough concurrent commits arrive and the workload is limited by commit flush cost. PostgreSQL explicitly warns that excessive commit_delay can increase latency enough to reduce total throughput. Benchmark the actual device and concurrency level rather than assuming more batching is always better.


Checkpoints Bound the Recovery Starting Region

A Checkpoint Establishes a Durable Baseline

At checkpoint time, a database drives a defined set of dirty data toward durable storage and records checkpoint information in WAL or control metadata.

Recovery Can Start From a Later Redo Position

PostgreSQL’s current WAL configuration documentation says checkpoints guarantee that heap and index files contain information written before the checkpoint’s redo boundary. Crash recovery can therefore start REDO from the location identified by the checkpoint rather than scanning the entire lifetime of the database.


Checkpoints Do Not Mean the Database Stops Changing

Foreground Work Continues in Modern Systems

Checkpoint page writes are often spread across time to avoid an I/O spike. New transactions continue producing WAL while the checkpoint progresses.

The Baseline Is Carefully Defined

The exact redo starting point is not simply the wall-clock instant when the checkpoint command finishes. Production engines track the WAL positions and dirty-page obligations needed to state which earlier changes are safely represented in data files.


Frequent Checkpoints Shorten Recovery but Increase Steady-State Work

More Frequent Baselines Mean Less WAL to Replay

After a crash, fewer post-checkpoint records may need redo.

But Checkpoints Force More Page Writes

PostgreSQL documents the trade-off directly: shorter checkpoint intervals reduce recovery work but increase dirty-page flushing and can also increase WAL volume due to full-page writes. Recovery-time goals and foreground I/O goals therefore pull in opposite directions.


Full-Page Protection Handles Torn-Page Risk

A Page Write Can Be Interrupted

Storage may contain a page image that is neither the complete old page nor the complete new page after a crash.

Logging a Full Page Image Can Restore Consistency

PostgreSQL’s full_page_writes mechanism records a full page image on the first page modification after a checkpoint under its normal configuration. During recovery, that image can restore a consistent page before later WAL changes are replayed. Other engines solve torn-write risk with different page, checksum, doublewrite or atomic-write techniques.


Crash Recovery Is a Replay Problem

Restart Finds a Safe Starting Point

The engine identifies the latest usable checkpoint or equivalent recovery metadata.

Then WAL Is Scanned Forward

Records after the redo position are interpreted in order and applied when necessary. PostgreSQL’s WAL internals documentation describes reading control information, locating the checkpoint and scanning forward from the redo record.


Redo Must Be Safe When a Page Already Contains the Change

Recovery Can Encounter Partially Persisted Work

Some pages were written before the crash, others were not, and a single page might already contain changes represented in the WAL stream.

Idempotent or Position-Aware Replay Prevents Double Application

The recovery system compares page state or WAL positions so replay does not blindly apply the same physical effect twice. The exact method is implementation-specific, but recovery must tolerate arbitrary subsets of dirty pages having reached storage before failure.


Not Every Database Uses the Same Undo Model

ARIES-Style Systems Can Redo History and Undo Losers

Some classic recovery designs explicitly redo actions then logically undo transactions that did not commit.

PostgreSQL Uses Its Own MVCC and Transaction-Status Model

PostgreSQL crash recovery primarily replays WAL to restore data-page consistency, while tuple visibility and transaction status determine whether effects from incomplete transactions are visible. Avoid describing one engine’s recovery sequence as a universal WAL law.


WAL Segments Are Physical Containers for the Stream

The Logical Stream Is Divided Into Files

PostgreSQL stores WAL in sequentially numbered segment files under pg_wal. The stream is continuous conceptually even though it crosses physical files.

Segment Lifecycle Depends on Recovery and Replication Needs

Old segments can be recycled or removed after checkpoints only when no archive, standby, replication slot, backup or other retention obligation still needs them. Disk usage therefore reflects more than checkpoint age.


Replication Reuses the WAL Stream

Physical Standbys Can Replay WAL

The same ordered change stream used for local crash recovery can be shipped to another server and replayed there.

Durability Modes Can Extend the Commit Boundary

With synchronous replication, a transaction can wait for remote receipt, remote write, remote durable flush or remote apply depending on the system and configuration. PostgreSQL exposes several synchronous_commit modes that distinguish those guarantees.


Logical Replication Is Related but Not Identical

Physical WAL Contains Storage-Level Changes

Those records can include page-level information not suitable as a portable row-change protocol.

Logical Decoding Extracts Higher-Level Changes

PostgreSQL’s wal_level and logical decoding facilities add information required to interpret changes at the logical replication layer. WAL is therefore a substrate that can support several consumers with different representations.


Archiving WAL Enables Point-in-Time Recovery

A Base Backup Supplies a Starting Data Image

The backup need not be taken at one instantaneous moment if the recovery protocol captures the required WAL interval correctly.

Archived WAL Advances the Backup Forward

PostgreSQL’s WAL introduction explains that archived WAL can be replayed after a physical backup to recover to a desired time covered by available WAL. This extends WAL from crash recovery into a historical recovery mechanism.


WAL Is Not a Substitute for a Backup

The Log Usually Depends on a Data Baseline

Replaying WAL forever from database creation is not the normal backup strategy.

Catastrophic Loss Can Destroy Both Data and Local WAL

A separate backup and WAL archival policy protects against wider failure domains. Local write-ahead logging primarily ensures transactional durability and crash recovery for the database’s storage model.


WAL Retention Can Become a Disk-Space Problem

Replication Slots and Failed Archiving Can Pin Old Segments

A standby that falls behind or an archive destination that fails can prevent normal recycling.

Disk Exhaustion Becomes an Operational Risk

Monitoring must distinguish active WAL generation from retained historical segments. Raising max_wal_size does not override every retention reason. PostgreSQL documents that archive failures and replication slots can keep older WAL regardless of ordinary checkpoint sizing.


WAL Volume Depends on Workload and Page Behaviour

One Logical Byte Can Generate More Than One WAL Byte

Indexes, metadata changes, page images and record headers contribute.

Checkpoint Timing Influences Full-Page Images

With full_page_writes enabled, the first modification of a page after each checkpoint can log the entire page image. A very frequent checkpoint cycle can therefore increase WAL volume even if application write volume stays constant.


Sequential WAL Writes Are Friendly to Storage

The Stream Appends in Order

Compared with synchronously flushing many unrelated table and index pages, appending WAL concentrates durable commit traffic into a mostly sequential stream.

But Storage Caches and fsync Semantics Still Matter

The operating system can acknowledge a write to page cache before the device has made it durable. Databases use fsync, fdatasync, O_SYNC-style modes or platform equivalents to cross the durability boundary their configuration promises.


The Difference Between Write and Flush Matters

Write Can Mean Copy to the Kernel

Bytes can leave database buffers and enter the operating-system cache.

Flush Means Request Durable Completion

PostgreSQL’s current WAL configuration distinguishes WAL writes from fsync-style synchronization and exposes I/O timing counters for them. Performance diagnosis should not call both events simply ‘disk write’ if commit latency is dominated specifically by synchronization.


WAL Buffers Absorb Record Generation

Sessions Produce WAL Into Shared Memory

The engine accumulates records before writing them into segment files.

Too Little Buffering Can Move I/O Into Critical Paths

PostgreSQL notes that XLogInsertRecord can be forced to write WAL when buffers are full, which is undesirable because low-level modifications may hold page locks. Buffer sizing can therefore affect response-time smoothness under high WAL generation.


WAL Protects Page Reordering by the Buffer Manager

Data Pages Can Be Written in a Different Order Than Transactions

A background writer may flush page B before page A even if the transaction modified A first.

Recovery Relies on the Log Order Instead

As long as write-ahead requirements are satisfied, physical page-write order does not need to mirror transaction order. The WAL stream becomes the authoritative recovery sequence while the buffer manager optimises data-page writeback.


A Transaction Can Touch Many Pages but Need One Commit Flush

Page Count and Commit Count Are Different Dimensions

A transaction updating a thousand rows may dirty many pages but ultimately waits for its WAL through one commit durability boundary.

The Dirty Pages Can Drain Later

This decoupling lets the buffer manager cluster and schedule page writes efficiently. It also means a system with fast commits can still accumulate dirty-page pressure if background writeback cannot keep up.


WAL and MVCC Solve Different Problems

WAL Answers Durability and Recovery

It records changes so storage state can be rebuilt after failure.

MVCC Answers Visibility Under Concurrency

It decides which row versions a transaction can see. The two interact—for example, recovery restores physical versions and transaction status while MVCC decides visibility—but neither mechanism substitutes for the other.


WAL and LSM Logging Are Related but Not the Same Architecture

An LSM Engine Often Uses a WAL for Recent-Write Recovery

The LSM write buffer can be volatile, so a log protects accepted writes before their SSTable flush.

But WAL Is Not What Makes the Store an LSM Tree

LSM refers to the organisation of mutable memory plus immutable sorted runs and compaction. A B-tree storage engine can also use WAL. Logging and indexing are orthogonal design layers.


Common Failure: Data Reaches Disk Before Its WAL

Why It Is Dangerous

A crash can leave a data page containing a change with no durable recovery record.

What the System Must Enforce

Before the page write becomes durable, every WAL record required to reconstruct or interpret that page state must already satisfy the write-ahead durability condition. This is the invariant around which page flushing is organised.


Common Failure: Success Is Returned Before the Promised Durability Point

The Application Thinks the Transaction Is Safe

It performs an external action based on that promise.

A Crash Loses the Commit

If asynchronous commit was intentionally configured, that can be within contract. If synchronous durability was promised, it is a correctness bug. The acknowledgement boundary must match the application’s expectation.


Common Failure: Checkpoints Are Forced Too Often

The Database Spends Excessive Time Flushing Dirty Buffers

Latency becomes spiky and storage bandwidth shifts toward checkpoint work.

WAL Volume Can Increase Too

Full-page protection after checkpoints adds further output. PostgreSQL recommends avoiding checkpoints that are too frequent and exposes checkpoint_warning to reveal repeated pressure.


Common Failure: Recovery Is Tested Only After Clean Shutdown

Clean Shutdown Already Writes an Orderly State

It does not exercise the crash path.

Crash Tests Must Interrupt Real Work

Use a disposable environment, generate committed and uncommitted changes, force an abrupt process or machine failure under controlled conditions, restart and compare the recovered logical state with an independent oracle. Never use fault injection on production data without a proven recovery plan.


Common Failure: WAL Disk Usage Is Treated as a Fixed Size

Retention Is Dynamic

Checkpoint interval, generation rate, archive lag, replication slots, backup needs and standbys all affect how much WAL must remain.

Capacity Planning Needs Headroom

Monitor oldest required WAL positions and growth rate. A system can exceed nominal sizing during bursts or when downstream consumers stall. Running out of WAL storage can become a database availability event.


Testing the Write-Ahead Invariant

Generate Dirty Pages Faster Than Checkpoint Writeback

The system should still recover because WAL contains the necessary changes.

Inspect Ordering With Built-In Tools Where Available

PostgreSQL offers statistics and testing utilities such as pg_test_fsync and WAL inspection facilities. Use product-supported tools rather than modifying segment files directly. The goal is to verify the engine’s durability path, not to invent a parallel one.


A Simple Commit-Latency Laboratory

Run One Client First

Measure transactions per second and commit latency with synchronous durability on a disposable database.

Increase Concurrent Committers

Observe whether throughput rises as group commit amortises flush cost. Then compare asynchronous commit only if the experiment’s purpose permits a weaker durability contract. Label the guarantee beside every number; a faster benchmark with weaker durability is not a like-for-like comparison.


A Simple Crash-Recovery Laboratory

Create a Known Data History

Insert rows, commit some, leave another transaction open, and generate enough activity to dirty many pages.

Crash and Restart

After restart, committed logical state should remain, incomplete work should follow the engine’s transaction rules, indexes should be usable and consistency checks should pass. Repeat around checkpoint timing to exercise different redo lengths. Record database version, filesystem and durability settings.


Visual Analogy: WAL Is the Receipt Printed Before the Warehouse Moves the Box

The Receipt Proves What Must Be Reconstructible

The warehouse can rearrange shelves later because the durable receipt says what happened in the authoritative order.

A Shelf Move Without a Receipt Is Dangerous

If the building loses power, nobody can tell whether the new shelf state is complete. The write-ahead rule is therefore a sequencing discipline, not merely record-keeping.


How the Parts Work Together: WAL Separates Decision Time From Material Reorganisation

The Transaction Layer Wants a Fast Durable Decision

The storage layer wants freedom to schedule expensive page writes efficiently.

WAL Connects Them

The log establishes an ordered durable narrative; checkpoints and background writers gradually make data files catch up. Recovery reconciles the two after failure. This separation is a recurring systems pattern: record the irreversible decision cheaply, then complete heavier material work asynchronously.


Frequently Asked Questions

Does WAL Mean Every Data Page Is Written Twice?

Not necessarily in the simple sense of identical bytes. WAL records and later data-page writes are different representations. Full-page images can increase duplication at some points, while compact change records can be much smaller than pages. Write amplification depends on workload and engine.

Is fsync the Same as Writing?

No. A write may move data to kernel cache. A synchronization operation requests that the relevant data reach the durability boundary defined by the operating system and storage stack. Databases distinguish these because commit guarantees depend on durable completion.


More Frequently Asked Questions

Can WAL Recover From Any Disaster?

No. WAL supports crash recovery and, with archival plus a base backup, can support broader recovery scenarios. Loss or corruption of all required data and WAL copies still needs backups or replicas.

Why Not Flush All Data Pages at Commit?

Because one transaction can touch many pages in many files. WAL lets the database make one sequential durability stream the commit bottleneck and schedule random page writes later, usually improving throughput.


The Series Map and Sources

Pillars in This Cluster

The Checkpoints pillar owns dirty-page flushing and redo boundaries. The Group Commit pillar owns shared WAL flushes, fsync amortisation and commit latency. The Crash Recovery pillar owns restart, checkpoint selection, REDO replay and treatment of incomplete transactions. The master connects those mechanisms.

Sources and Further Reading

The principal concrete reference is PostgreSQL 18’s current Write-Ahead Logging introduction, WAL configuration guide and WAL internals. These document PostgreSQL, not a universal binary WAL format.


Final Synthesis: WAL Lets Durability Lead and Page Reorganisation Follow

The Mechanism

Record recoverable changes in an ordered log, flush that log to the required durability point before dependent data pages, acknowledge commits according to the configured contract, write dirty pages later, checkpoint periodically and replay the log after a crash.

Why It Matters

The database separates a fast sequential durability path from slower page-oriented storage work. Group commit shares synchronization cost. Checkpoints bound recovery. WAL replay closes the gap after failure. The whole design depends on one non-negotiable ordering rule: the recovery record must become durable before the data change is allowed to outrun it.

Worked WAL Timeline: Commit Before the Data Page Reaches Disk

Step 1: The Transaction Changes Memory

Suppose transaction T updates one row and one index entry. The buffer pool now contains two dirty pages. The on-disk copies can still show the earlier row value and earlier index state. The transaction also generates WAL records describing the changes, followed eventually by a commit record.

Step 2: The WAL Reaches the Durable Boundary First

The database flushes the WAL through T’s required commit position. Once the configured durability condition is satisfied, T can be reported committed even though the table and index pages remain dirty in memory. A later background write may persist the heap page first and the index page second, or vice versa. WAL makes that physical ordering safe because recovery can reconstruct the durable logical outcome after a crash.

Worked Failure Timeline: Crash Between WAL Flush and Page Flush

Imagine the WAL for transaction T is durable, the heap page has not been written, and the index page was written just before power loss. At restart, the database cannot assume all of T is missing or all of T is present. It must inspect surviving page state and replay the ordered WAL as required. One page can already reflect the change while another still needs redo.

This is the scenario that makes write-ahead logging valuable. Commit durability does not require synchronous random writes to every page, yet crash recovery still has a deterministic source of truth. The page write schedule can be optimized for throughput while the WAL stream preserves the recovery order.

WAL Positions Are Useful Beyond Recovery

Replication Progress Can Be Expressed as a WAL Position

A physical standby can report how far it has received, written, flushed or replayed the primary’s WAL. Those positions distinguish network transfer from local durability and from visibility on the standby. A single phrase such as “replica caught up” is therefore incomplete without naming which stage has caught up.

Backups and Recovery Targets Can Also Be Positioned in the Stream

Physical backup and point-in-time recovery procedures use WAL positions to establish which log interval is needed to turn a base image into the desired database state. The ordered stream becomes a coordinate system for both durability and historical reconstruction.

Why WAL Does Not Eliminate Random Data Writes

WAL moves the immediate commit bottleneck toward sequential logging, but the database still has to persist table and index pages eventually. Background writers and checkpoints perform those page-oriented writes later. If storage cannot sustain the long-run dirty-page generation rate, buffers fill and latency eventually appears elsewhere.

The correct claim is therefore that WAL decouples transaction commit from immediate data-page flushing. It does not make data-page I/O disappear. Sustainable performance requires both a healthy WAL path and a healthy page-writeback path.

The Durability Stack Has Several Layers

Database Buffers, Kernel Cache and Device Cache Are Different Places

Moving bytes out of the database’s shared memory is not necessarily equivalent to making them durable. The operating system may cache them, and the storage device may have another volatile cache. WAL guarantees depend on the operating system and hardware honoring the synchronization primitives the database uses.

Virtualized and Cloud Storage Need the Same Scrutiny

A virtual disk can sit above several layers of caching and replication. The database still needs a trustworthy definition of what a successful flush means. Production durability is therefore a contract across software, kernel, hypervisor, storage service and device, not a property created by one function call in isolation.

WAL Retention Is a Dependency Graph

One segment can be unnecessary for local crash recovery yet still required by a lagging replica, a replication slot, an archive destination, a base backup or a point-in-time recovery policy. These consumers can have different oldest-needed positions.

The safe recycling point is therefore constrained by the oldest active obligation, not merely by the latest checkpoint. Monitoring should expose why a segment is retained. Otherwise operators can misdiagnose growing WAL as “checkpoint failure” when the real cause is a stalled consumer.

WAL Volume Is an Operational Signal, Not Just a Storage Cost

A sudden increase in WAL bytes can reveal heavier write workload, more index maintenance, frequent full-page images, bulk operations or configuration changes. Comparing WAL bytes with application-level changed bytes helps explain write amplification inside the database.

Yet WAL volume alone does not measure commit latency. A system can generate large sequential WAL efficiently while commit fsync remains fast, or generate little WAL while each synchronization is slow. Track volume, write time, sync time and group size separately.

A Production WAL Audit Checklist

Confirm the intended durability mode, current WAL generation rate, average and tail WAL sync latency, checkpoint frequency, dirty-buffer pressure, oldest retained WAL dependency, replication lag, archive health and free space in the WAL filesystem. Then compare those observations with the application’s RPO and RTO requirements.

This checklist prevents one-dimensional tuning. Faster commit latency achieved by weakening synchronous durability may violate RPO. Larger checkpoint intervals may smooth I/O while violating RTO. More WAL retention may protect replicas while risking disk exhaustion. The architecture works only when the trade-offs are stated together.

WAL Review: The Durable Prefix Is the Central Abstraction

At any moment, the WAL stream has a durable prefix and a newer suffix that may exist only in database or operating-system memory. Synchronous commit waits until its required commit position lies inside that durable prefix. Group commit advances the prefix for several transactions at once. Replication reports how far remote systems have received, written, flushed or replayed the same stream.

This prefix model is the shortest way to connect the cluster. Checkpoints decide how much of the durable prefix has already been materialised into data files. Crash recovery replays the durable prefix beyond the redo boundary. WAL retention preserves the part of the stream still needed by recovery, replicas or backups.


Continue the How X Works Series

How X Works Hub · How MVCC Works · How LSM Trees Work