Home sqlite-checkpointing
Post
Cancel

sqlite-checkpointing

Doc

Of course, one wants to eventually transfer all the transactions that are appended in the WAL file back into the original database.

Moving the WAL file transactions back into the database is called a “checkpoint”.

Another way to think about the difference between rollback and write-ahead log is that in the rollback-journal approach, there are two primitive operations, reading and writing, whereas with a write-ahead log there are now three primitive operations: reading, writing, and checkpointing.

By default, SQLite does a checkpoint automatically when the WAL file reaches a threshold size of 1000 pages. (The SQLITE_DEFAULT_WAL_AUTOCHECKPOINT compile-time option can be used to specify a different default.) Applications using WAL do not have to do anything in order to for these checkpoints to occur. But if they want to, applications can adjust the automatic checkpoint threshold. Or they can turn off the automatic checkpoints and run checkpoints during idle moments or in a separate thread or process.

PRAGMA checkpoint_fullfsync PRAGMA checkpoint_fullfsync = boolean;

Query or change the fullfsync flag for checkpoint operations.

If this flag is set, then the F_FULLFSYNC syncing method is used during checkpoint operations on systems that support F_FULLFSYNC. The default value of the checkpoint_fullfsync flag is off. Only Mac OS-X supports F_FULLFSYNC.

This post is licensed under CC BY 4.0 by the author.