Comment

Comment by simonw

Something I found non-obvious about WAL mode in SQLite is that it's actually a property of the database file itself.

When you run "PRAGMA journal_mode=wal;" against a database file the mode is permanently changed for that file - and the .db-wal and .db-shm files for that database will appear in the same directory as it.

Any future connections to that database will use it in WAL mode - until you switch the mode on it back, at which point it will go back to journal mode.

It makes sense when you think about it - of course a database can only be in one or the other modes, not both, so the setting must be at the database file level. But it took me a while to understand.

I wrote some notes on this here: https://til.simonwillison.net/sqlite/enabling-wal-mode

parent simonw 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton