SQLite WAL Checkpoint Explained: How Reads and Writes Work Together
Learn how SQLite WAL mode commits changes, preserves consistent reader snapshots and checkpoints data into the main database. Understand its concurrency limits, growing log files and durability trade-offs.
On this page
A SQLite application can keep serving readers while another connection saves changes, but that does not mean its database file is being updated immediately. In Write-Ahead Logging (WAL) mode, SQLite first records changes in a separate log and copies them into the main database later. Understanding that separation explains why WAL can improve concurrency, why a database may have a surprisingly large extra file, and why a long-running read can slow down maintenance.
This explanation applies to SQLite 3.54.1, released on October 16, 2026, and its established WAL implementation. The central idea is simple: committed changes enter the log first, readers use a consistent view of the database, and a checkpoint eventually transfers logged changes into the main database file. SQLite documents this behaviour in its WAL documentation.
The short answer: WAL separates committing from updating the database file
In the default rollback-journal mode, SQLite protects a transaction by recording original database content before changing the database file. WAL reverses that order: it preserves the existing database file and appends changed pages to a separate write-ahead log. A transaction becomes committed when SQLite writes a valid commit record into that log. Readers can continue using the older database state while the new committed state waits in the log, so reading and writing can overlap without readers having to wait for every database update.
There is one important qualification: WAL does not allow several writers to modify the same database simultaneously. SQLite still permits only one active writer at a time. WAL improves the relationship between readers and a writer; it does not turn a single database file into a multi-writer system.
Why SQLite writes to a separate file first
Think of a database as a set of pages rather than one large document. A page is a fixed-size unit of database storage, and a transaction may change one or several pages. In rollback-journal mode, SQLite saves the original versions of affected pages in a journal before modifying the main database. If the transaction fails, those original pages can restore the previous state. The commit process is tied to completing the journal operation and making the database changes safe.
WAL takes a different route. Instead of immediately replacing the affected pages in the main database, SQLite appends their new versions to a file commonly named after the database with a -wal suffix. It also records transaction information, including a commit marker. Once the commit record is valid, the transaction is committed even though the main database file may still contain older page versions. This is why the WAL file is not merely a temporary performance cache: it can contain committed data that the main database has not received yet.

How a reader sees a consistent version of the data
Allowing reads and writes to overlap creates a question: if a writer adds new pages while a reader is halfway through a query, which version should that reader see? SQLite solves this with a snapshot boundary called an end mark. When a read transaction begins, it remembers the position of the last valid commit record in the WAL. That position remains fixed for the duration of the read transaction, so the reader sees a consistent database state even if another connection commits newer changes.
When SQLite needs a page, it checks whether a newer version of that page exists in the WAL before the reader's end mark. If one does, SQLite uses the latest eligible version. If not, it reads the page from the main database file. A shared-memory structure called the WAL index helps SQLite locate relevant pages without repeatedly scanning the entire log. The result resembles reading a saved snapshot of a document: later edits can be committed, but an existing reader continues to see the version that was available when its transaction began.
This explains why a reader does not automatically see every change committed after its transaction starts. A new query in a new read transaction can see newer committed data, while a query inside an existing transaction remains tied to its original snapshot. Applications that keep read transactions open for a long time can therefore hold back maintenance even when their queries are not actively fetching rows.
A checkpoint moves committed pages into the main database
The process that transfers WAL content back into the main database is called checkpointing. It does not create a new transaction or decide whether an earlier transaction should commit. It copies eligible page changes from the log into the database file, making it possible to reuse or reset the WAL after the relevant readers and writers are finished. SQLite normally runs automatic checkpoints when a commit causes the WAL to reach approximately 1,000 pages, although the threshold can be configured and the exact file size depends on the database page size.
A checkpoint must respect the end marks of active readers. Suppose a reader began before a newer transaction was committed and is still using an older page version. Replacing that page in the main database too early could remove the version the reader needs. SQLite therefore stops a checkpoint when it reaches content that cannot safely be transferred past an active reader's snapshot. It can resume later, once the blocking read transaction has ended.

SQLite's default automatic checkpoint is designed to handle ordinary workloads without requiring application code to manage the log manually. The default mechanism performs a passive checkpoint, meaning it makes as much progress as it can without forcing active readers or writers out of the way. This is usually a sensible starting point, but it does not guarantee that every checkpoint finishes immediately.
Why the WAL file can grow even when writes are working
A growing WAL file does not necessarily mean SQLite has stopped committing transactions. It can mean that new writes are arriving faster than checkpointing can safely transfer and recycle old log content. The most important cause is checkpoint starvation: if read transactions overlap continuously, there may never be a suitable gap in which a checkpoint can finish and reset the log. A large write transaction can also temporarily create a large WAL because SQLite cannot reset the log in the middle of that transaction.
Consider an application that opens a read transaction, performs a query, and then keeps the transaction open while it does unrelated work. Meanwhile, other connections continue committing updates. The reader's snapshot may prevent a checkpoint from completing, so the WAL retains content needed by that reader. Repeating this pattern can cause the log to grow and make subsequent reads more expensive. The problem is not simply the number of queries; it is how long transactions remain active.
SQLite uses the WAL index to make page lookup efficient, but its documentation warns that read performance can deteriorate as the WAL grows. The index reduces the cost of finding a page; it does not eliminate the work associated with a large log or remove the need for checkpoint progress. Developers should therefore treat transaction lifetime and checkpoint behaviour as related operational concerns rather than assuming that automatic checkpointing makes WAL size irrelevant.
WAL is not the same as unlimited write concurrency
The most common misunderstanding is that WAL allows every connection to write independently. It does not. A single WAL file means SQLite still serializes write transactions: one writer appends changes while other writers must wait or receive a busy result. WAL mainly removes the usual reader-versus-writer conflict, allowing readers to continue from their snapshots while a writer commits new pages.
This is closer to a shared notebook with one person allowed to edit at a time while several people read earlier copies. The readers do not need to stop every time the editor writes, but two editors still cannot safely append independent changes simultaneously. The comparison is not exact because SQLite manages page versions, locks, commit records and snapshots automatically, but it captures the key distinction between read concurrency and write concurrency.

When WAL is a poor fit
WAL is not suitable when multiple machines need to access the same database file through a network filesystem. Its shared-memory coordination requires participating processes to run on the same host, so placing a WAL-mode database on a network share is not a safe way to create a shared multi-server database. Applications that need independent writers across multiple machines should consider a database architecture designed for that workload instead.
WAL also does not remove the need to handle busy results, keep transactions reasonably short, or choose an appropriate durability setting. SQLite documents that synchronous=NORMAL in WAL mode can preserve database consistency while allowing a recently committed transaction to be lost after a power failure or system crash; synchronous=FULL adds a sync operation at each commit to improve durability. These settings are a trade-off, not a free performance switch, and the synchronous pragma documentation explains their differences.
What to check before enabling it in an application
For a local application with many reads and relatively short writes, WAL is often a useful option. It can reduce the time readers spend waiting for writers and make write activity more sequential. Before enabling it, check that every process accessing the database runs on the same machine, that the application closes read transactions promptly, and that its durability requirements match the selected synchronous setting.
WAL mode is enabled through PRAGMA journal_mode=WAL;, and the returned value should be checked because SQLite may be unable to switch modes if the underlying filesystem or virtual file system lacks the required shared-memory support. The setting persists for the database, so it is not merely a per-query preference. The journal mode documentation describes the available modes and the result returned when a change cannot be made.
After enabling WAL, monitor the size of the -wal file and investigate sustained growth alongside long-running read transactions and checkpoint progress. Do not delete the WAL file manually while the database is in use: it may contain committed changes that have not yet reached the main database. If the application needs to copy or move a live database, use SQLite's supported backup mechanisms rather than treating the main database file as the complete dataset.
The practical rule is to manage transaction lifetimes first
WAL works well when readers finish their snapshots and allow checkpoints to make progress. It becomes harder to manage when applications leave transactions open while waiting for user input, performing network requests, or processing unrelated tasks. Those patterns can turn a feature intended to improve concurrency into a source of disk growth and uneven query latency. Before changing checkpoint thresholds or forcing aggressive checkpoints, inspect how long read transactions remain active; shortening those transactions is often the more direct fix.
Share this post
Written by



