SQLite插入性能
我需要将行写入文件服务器上的文件。我正在考虑使用 SQLite 来确保一行的写入成功,而不仅仅是部分完成。插入性能至关重要。
SQLite向表中插入一行的具体过程是怎样的?该表没有索引、主键、约束或任何东西。
I need to write lines to a file on a file server. I am considering SQLite to ensure writing of a line is successful and not just partially completed. Insert performance is essential.
What is the exact process when SQLite inserts a row into a table? The table does not have indexes, primary keys, constraints or anything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该使用事务,从而尽量避免在每个
INSERT
上使用fsync()
。请查看此处了解一些基准测试。另外,请务必正确设置两个重要的
pragmas
:正常
)WAL)
You should use transactions and thus try to avoid
fsync()
-ing on everyINSERT
. Take a look here for some benchmarks.Also, be sure to properly set the two important
pragmas
:NORMAL
)WAL
)您可以使用解释来详细了解执行语句时会发生什么: http://www.sqlite.org/lang_explain .html
you can use explain for details what happens when you execute a statement: http://www.sqlite.org/lang_explain.html