Improve INSERT-per-second performance of SQLite

后端 未结 10 2223
忘掉有多难
忘掉有多难 2020-11-21 04:41

Optimizing SQLite is tricky. Bulk-insert performance of a C application can vary from 85 inserts per second to over 96,000 inserts per second!

Background:

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-21 05:41

    On bulk inserts

    Inspired by this post and by the Stack Overflow question that led me here -- Is it possible to insert multiple rows at a time in an SQLite database? -- I've posted my first Git repository:

    https://github.com/rdpoor/CreateOrUpdate

    which bulk loads an array of ActiveRecords into MySQL, SQLite or PostgreSQL databases. It includes an option to ignore existing records, overwrite them or raise an error. My rudimentary benchmarks show a 10x speed improvement compared to sequential writes -- YMMV.

    I'm using it in production code where I frequently need to import large datasets, and I'm pretty happy with it.

提交回复
热议问题