Help:Could I use SQLite in-memory database with WAL mode?
(1) By xxk on 2020-03-22 12:17:48 [link] [source]
Hi everyone, Recently I learned the SQLite in-memory database and used it in my little project. In order to support more concurrency I decide to use WAL mode, but when I learned the content from website I have two questions : 1.Does SQLite in-memory database support WAL mode? 2.If it does, where is it's Write-Ahead Log located? Thanks a lot in advance, xxk
(2) By Keith Medcalf (kmedcalf) on 2020-03-22 15:14:49 in reply to 1 [link] [source]
No. Memory only databases only use write behind logging with the log stored in memory (memory), or no logging (off). They cannot be configured to use any other logging mode including write-ahead logging (WAL).
(3.2) By ddevienne on 2020-03-23 09:25:08 edited from 3.1 in reply to 2 [source]
But you can still have multiple connections open that memory DB
by using a URI. You won't get WAL's MVCC, but if you want to parallelize
some reads for example, you can, and it does scale, just not linearly
nor to large concurrent accesses. It does force you to Shared-Cache,
which necessarily adds contention on the cache, and is not in general
a recommended option, unless you're on very constrained devices.
Worth trying for yourself IMHO. FWIW. --DD
PS: Another much more complex option is to create your own VFS,
which emulates a RAM disk, and since WAL uses shared-memory,
probably also SHM too. Not sure that's possible in WAL mode.