How to improve SQLite insert performance in Python 3.6?

前端 未结 1 1738
予麋鹿
予麋鹿 2021-02-04 08:26

Background

I would like to insert 1-million records to SQLite using Python. I tried a number of ways to improve it but it is still not so satisfied. The database load

1条回答
  •  抹茶落季
    2021-02-04 08:52

    If python's interpreter is actually a significant factor in timing (section 9) vs SQLite performance, you may find PyPy to improve performance significantly (Python's sqlite3 interface is implemented in pure python.) Here not much is done in pure python, but if you were doing more string operations or had for loops then it is worth it to switch from CPython.

    Obviously if performance outside SQLite really matters you can try writing in a faster language like C/C++. Multi-threading may or may not help depending on how the database locks are implemented.

    0 讨论(0)
提交回复
热议问题