synchronous

Queries or sets the disk synchronization strategy.

This pragma controls how carefully SQLite commits data to the disk to ensure durability in the event of a power failure or OS crash. It offers a trade-off between safety and performance.

The value is a Synchronous enum, which corresponds to the following modes:

  • Synchronous.OFF (0): Completely disables synchronization. Fastest but least safe; a crash can corrupt the database.

  • Synchronous.NORMAL (1): Syncs at critical moments, but not for every write. Generally safe from corruption, but recent transactions might be lost on a crash.

  • Synchronous.FULL (2): (Default) Ensures all writes are fully committed to disk before a transaction completes. Very safe but slower.

  • Synchronous.EXTRA (3): Like FULL, but with extra synchronization for added durability on some systems.

In WAL mode, NORMAL is as safe as FULL, making it a good choice for performance without sacrificing reliability.

Author

MOHAMMAD AZIM ANSARI

See also