Improve INSERT-per-second performance of SQLite

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

    Try using SQLITE_STATIC instead of SQLITE_TRANSIENT for those inserts.

    SQLITE_TRANSIENT will cause SQLite to copy the string data before returning.

    SQLITE_STATIC tells it that the memory address you gave it will be valid until the query has been performed (which in this loop is always the case). This will save you several allocate, copy and deallocate operations per loop. Possibly a large improvement.

提交回复
热议问题