内存 SQLite 数据库可以通过并发扩展吗?
为了防止 SQLite 内存数据库被清理,必须使用相同的连接来访问数据库。但是,使用相同的连接会导致 SQLite 同步对数据库的访问。因此,如果我有许多线程对内存数据库执行读取,则在多核计算机上运行的速度比对文件支持的数据库运行完全相同的代码要慢。
有什么办法可以两全其美吗?也就是说,内存数据库允许对数据库进行多个并发调用?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
答案是否定的。我向 SQLite 用户组询问并得到 Pavel Ivanov 的以下回复:
The answer is no. I asked on the SQLite user group and got the following response from Pavel Ivanov:
如果将页面大小和缓存大小设置得足够大以容纳整个数据库,则读取操作将从缓存中完成,性能将几乎等于内存数据库。
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.
从这里我明白答案是肯定的 http://www.sqlite.org/faq.html# q6
from here i understood that answer is yes http://www.sqlite.org/faq.html#q6