SQLite insert performance

2019-02-09 17:30发布

I need to write single lines to a file placed on a file server. I am considering utilizing SQLite to ensure that the writing of the line was successful and not just partially completed. However, as insert performance is really essential. My question is, what is the exact process (as it read this, write that, read this and so on) that SQLite goes through when it inserts a row to a table. The table does not have any indexes, nor primary keys, constraints or anything.

3条回答
啃猪蹄的小仙女
2楼-- · 2019-02-09 18:09

This is the most common bottleneck in my experience:

http://www.sqlite.org/faq.html#q19

Except for that, SQLite is really fast. :)

查看更多
迷人小祖宗
3楼-- · 2019-02-09 18:09

you can use explain for details what happens when you execute a statement: http://www.sqlite.org/lang_explain.html

查看更多
三岁会撩人
4楼-- · 2019-02-09 18:14

You should use transactions and thus try to avoid fsync()-ing on every INSERT. Take a look here for some benchmarks.

Also, be sure to properly set the two important pragmas:

查看更多
登录 后发表回答