但是,这不是解决错误的查询和表格的灵丹妙药.在到达内存数据库以提高性能之前,请确保优化表设计,查询和索引.
主要缺点是一旦进程关闭数据库就消失了.并且数据库不能大于可用内存.
提交可能更快,因为不需要写入磁盘,因此自动提交模式可能更快,但仍应将事务用于数据完整性目的.
请注意,不会太大的临时sqlite数据库可能会存储在内存中.
由于它的缺点,并且因为内存比存储少得多,所以在提交到内存数据库之前,请尝试使用临时数据库.这是通过使用”作为数据库文件名来完成的.这将写入临时文件,但缓冲内存缓存中的工作.它是两全其美的,你可以在不使用太多内存的情况下提高性能.
Even though a disk file is allocated for each temporary database,in practice the temporary database usually resides in the in-memory pager cache and hence is very little difference between a pure in-memory database created by “:memory:” and a temporary database created by an empty filename. The sole difference is that a “:memory:” database must remain in memory at all times whereas parts of a temporary database might be flushed to disk if database becomes large or if sqlite comes under memory pressure.