SQLITE: PRAGMA temp_store = 内存
在所有优化指南中,人们都在谈论诸如 JOURNAL_MODE 或 SYNCHRONOUS 之类的编译指示,但我从未读过有关 TEMP_STORE 编译指示的任何内容?我预计它会产生很大的影响,那么为什么它从未被提及呢?
它的目的是将所有 SQLite 的内部临时表从磁盘(临时目录)移动到内存,这似乎比每次 SELECT 时访问磁盘要快得多?
In all optimization guides people talk about pragma's like JOURNAL_MODE or SYNCHRONOUS, but I never read anything about the TEMP_STORE pragma? I would expect it has a large impact, so why is it never mentioned?
It's purpose is to move all SQLite's internal temporary tables from disk (temp directory) to memory, which seems a lot faster than hitting the disk on every SELECT?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SQLite 在执行写入时会锁定整个数据库,因此我认为最好在继续下一个任务之前将数据放入盘片中。
将数据放入内存很可能是为了只需要临时数据存储的情况而保留的(正如 TEMP_STORE 名称所暗示的那样); 您必须刷新整个数据库。
您仍然需要提供一种方法来定期将数据刷新到磁盘(如果您想保存它),并且由于锁定不是细粒度的,因此 也就是说,TEMP_STORE并不是一种缓存机制。
SQLite locks the entire database when doing writes, so I would imagine that it is better to get the data onto the platters before proceeding with your next task.
Putting the data in memory is most likely reserved for those occasions when you would only want a temporary data store (as the TEMP_STORE name implies); you would still need to provide a method for periodically flushing the data to disk (if you want to save it), and since the locking is not granular, you would have to flush the entire database.
In other words, TEMP_STORE is not a caching mechanism.