Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can in-memory SQLite databases scale with concurrency?

In order to prevent a SQLite in-memory database from being cleaned up, one must use the same connection to access the database. However, using the same connection causes SQLite to synchronize access to the database. Thus, if I have many threads performing reads against an in-memory database, it is slower on a multi-core machine than the exact same code running against a file-backed database.

Is there any way to get the best of both worlds? That is, an in-memory database that permits multiple, concurrent calls to the database?

like image 539
Kent Boogaart Avatar asked Apr 02 '10 13:04

Kent Boogaart


1 Answers

The answer is no. I asked on the SQLite user group and got the following response from Pavel Ivanov:

No, SQLite doesn't support full concurrent access to any database. The only concurrency you can earn is having on-disk database without shared cache (so actually having several copies of the database in memory). Of course I don't consider option of concurrency from different processes.

like image 125
Kent Boogaart Avatar answered Sep 30 '22 04:09

Kent Boogaart