PRAGMA journal_mode statement.
Supported modes
| Mode | Description | Status |
|---|---|---|
wal | Write-Ahead Logging. The default mode for new databases. Provides good concurrency for readers and writers. | Stable |
mvcc | Multi-Version Concurrency Control. Enables concurrent transactions with snapshot isolation. | Experimental |
WAL mode
WAL mode is the default for all new Turso databases. In WAL mode:- Readers do not block writers and writers do not block readers.
- A single write transaction is allowed at a time. Concurrent writes fail with
SQLITE_BUSY. - Transactions use deferred or immediate locking (see Transactions).
MVCC mode
MVCC mode enables concurrent transactions with snapshot isolation. Multiple transactions can read and write simultaneously. Write-write conflicts are detected at commit time rather than at lock acquisition time. In MVCC mode, useBEGIN CONCURRENT to take advantage of optimistic concurrency. See Concurrent transactions for full details.
Querying the current mode
Switching modes
Switch to WAL mode:Checkpoint behavior on mode switch
Switching journal modes triggers a checkpoint to ensure all pending changes are persisted before the mode change takes effect. When switching from MVCC back to WAL mode, the MVCC log file is cleared after checkpointing.If a database is written to using MVCC mode and then opened again without MVCC, the changes are not visible unless the database was first checkpointed.
Legacy modes
The legacy SQLite journal modes (delete, truncate, persist, memory, off) are recognized by the parser but not supported. Attempting to switch to any of these modes returns an error.
MVCC limitations
The MVCC implementation is experimental and has the following known limitations:- Indexes cannot be created, and databases with indexes cannot be used in MVCC mode.
- All data is eagerly loaded from disk to memory on first access. Large databases may take a long time to start and will consume significant memory.
- Only
PRAGMA wal_checkpoint(TRUNCATE)is supported, and it blocks both readers and writers. AUTOINCREMENTis not supported. Tables withAUTOINCREMENTcannot be created or inserted into while MVCC is enabled.- Many features may not work, may work incorrectly, or may cause a panic.
- Queries may return incorrect results.
- Changes written using MVCC mode are not visible when the database is reopened without MVCC, unless the database was checkpointed first.