Improve INSERT-per-second performance of SQLite

后端 未结 10 2259
忘掉有多难
忘掉有多难 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:40

    Avoid sqlite3_clear_bindings(stmt).

    The code in the test sets the bindings every time through which should be enough.

    The C API intro from the SQLite docs says:

    Prior to calling sqlite3_step() for the first time or immediately after sqlite3_reset(), the application can invoke the sqlite3_bind() interfaces to attach values to the parameters. Each call to sqlite3_bind() overrides prior bindings on the same parameter

    There is nothing in the docs for sqlite3_clear_bindings saying you must call it in addition to simply setting the bindings.

    More detail: Avoid_sqlite3_clear_bindings()

提交回复
热议问题