5 ms·
> PRAGMA synchronous = NORMAL; > In NORMAL mode, the database engine syncs to disk only at critical moments (e.g., during checkpoints) rather than at every sin
by tnodir 2mo ago
> PRAGMA synchronous = NORMAL;
> In NORMAL mode, the database engine syncs to disk only at critical moments (e.g., during checkpoints) rather than at every single transaction commit. In WAL mode, this is completely safe from database corruption; even if the server crashes, only the uncommitted transactions in the WAL are lost, but the database integrity remains intact.
No, this is not safe.
You can lose the latest committed transaction with this pragma.
- lazyant 2mo agoI lost rows in a busy table until I changed to PRAGMA synchronous = FULL
- JSR_FDED 2mo agoSafe in this context means not corrupting the database. You might lose data, but the database will live on happily as if the missing data was never written to it. You don’t get half-committed transactions, and the database isn’t in a weird state.
- tnodir 2mo ago> even if the server crashes, only the uncommitted transactions in the WAL are lost I'm mainly referring to this quote. So, you can lose committed transactions too.
- chasil 2mo agoThen WAL mode is not safe for you. "Transactions involving multiple attached databases are atomic, assuming that the main database is not ":memory:" and the journal_mode is not WAL. If the main database is ":memory:" or if the journal_mode is WAL, then transactions continue to be atomic within each individual database file. But if the host computer crashes in the middle of a COMMIT where two or more database files are updated, some of those files might get the changes where others might not." https://sqlite.org/lang_attach.html https://sqlite.org/lang_attach.html