将使用:memory加载的SQLite数据库写入磁盘 [英] Writing a SQLite db loaded using :memory to disk

查看:286
本文介绍了将使用:memory加载的SQLite数据库写入磁盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在内存中生成相当大的(〜50Mb)SQLite3数据库,一旦完成上述数据库的生成,我就需要能够将其写入磁盘。使用PHP解决此问题的最佳方法是什么?



我尝试在磁盘上创建结构相同的SQLite3数据库,然后使用INSERTS进行填充,但到目前为止太慢了。在在线查看 PHP SQLite3文档时,我也有空白。 / p>

我发现的是 SQLite3备份API ,但不确定如何最好地通过PHP与之交互。有任何想法吗?

解决方案

备份API在PHP中不可用。



如果将所有INSERT包装到单个事务中,则速度应该可以。



您可以避免使用单独的temporay数据库,并通过< a href = http://www.sqlite.org/pragma.html#pragma_cache_size rel = noreferrer>将页面缓存大小增加以大于50 MB,禁用日记功能,并且禁用同步写入


I'm generating quite a substantial (~50Mb) SQLite3 database in memory that I need to be able to write to disk once the generation of said database is complete. What is the best way of approaching this using PHP?

I have tried creating a structurally identical SQLite3 db on disk, and then using INSERTS to populate it, but it is far too slow. I have also drawn a blank looking at the online PHP SQLite3 docs.

What I have found is the SQLite3 Backup API, but not sure how best to approach interfacing with it from PHP. Any ideas?

解决方案

The backup API is not available in PHP.

If you wrap all INSERTs into a single transaction, the speed should be OK.

You could avoid the separate temporay database and make the disk database almost as fast by increasing the page cache size to be larger than 50 MB, disabling journaling, and disabling synchronous writes.

这篇关于将使用:memory加载的SQLite数据库写入磁盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆