Get the latest tech news

SQLite (with WAL) doesn't do `fsync` on each commit under default settings


SQLite when used with WAL doesn’t do fsync unless specified.

A transaction committed in WAL mode with synchronous=NORMAL might roll back following a power loss or system crash. In WAL mode when synchronous is NORMAL (1), the WAL file is synchronized before each checkpoint and the database file is synchronized after each completed checkpoint and the WAL file header is synchronized when a WAL file begins to be reused after a checkpoint, but no sync operations occur during most transactions. If durability is not a concern, then synchronous=NORMAL is normally all one needs in WAL mode.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of wal

wal

Photo of commit

commit

Photo of fsync

fsync

Related news:

News photo

The Secret Life of Fsync (2023)

News photo

PSA: SQLite WAL checksums fail silently and may lose data

News photo

The Lost Art of Commit Messages