synchronous
How often SQLite waits for data to reach the disk (fsync).
- Default
2 (FULL)- Range
- 0 OFF, 1 NORMAL, 2 FULL, 3 EXTRA
- Restart needed
- No
- Default checked on
- SQLite 3.5x
What it does
FULL (2) syncs at every commit. NORMAL (1) syncs less: in WAL mode it never corrupts the database but a power loss can roll back the last transactions; in rollback-journal mode it carries a small corruption risk on power loss. OFF (0) hands writes to the OS without syncing. EXTRA (3) also syncs the journal's directory.
Default value
2 (FULL). FULL (a stock SQLite 3.5x build), in WAL mode too unless the build sets SQLITE_DEFAULT_WAL_SYNCHRONOUS.
Check the current value
PRAGMA synchronous; SELECT * FROM pragma_synchronous; -- table-valued form, usable in queries
Change it
PRAGMA synchronous = NORMAL; -- this connection only
No restart. It applies at once to the connection that runs it and is lost when that connection closes, so set it every time a connection opens.
When to change it
Use NORMAL together with WAL for most applications: commits get much faster and the database stays consistent.
What can go wrong
OFF can corrupt the database on power loss or OS crash; NORMAL in WAL mode can lose the most recent commits.
The closest setting on other engines
| Engine | Setting | Default | Restart |
|---|---|---|---|
| SQLite |
synchronous this page
|
2 (FULL) |
No |
| PostgreSQL |
synchronous_commit
|
on |
No |
| MySQL |
innodb_flush_log_at_trx_commit
|
1 |
No |
| SQL Server |
DELAYED_DURABILITY
|
DISABLED |
No |
Questions about synchronous
What is the default value of synchronous in SQLite?
2 (FULL). FULL (a stock SQLite 3.5x build), in WAL mode too unless the build sets SQLITE_DEFAULT_WAL_SYNCHRONOUS.
Does changing synchronous require a restart?
No. No restart. It applies at once to the connection that runs it and is lost when that connection closes, so set it every time a connection opens.
When should I change synchronous?
Use NORMAL together with WAL for most applications: commits get much faster and the database stays consistent.
Back to all SQLite settings, or check the SQLite manual for every option.
Check synchronous on your own server
SQLly runs the query above against SQLite and the other engines in this reference, from one desktop app on macOS, Windows and Linux.