开发者

Can in-memory SQLite databases scale with concurrency?

开发者 https://www.devze.com 2022-12-25 05:17 出处:网络
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 t

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开发者_如何学Go 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?


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.


If you set the page size and cache size large enough to contain the entire database, read operations will be fulfilled from the cache and the performance will be nearly equal to an in-memory database.


from here i understood that answer is yes http://www.sqlite.org/faq.html#q6

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号