Shelve is too slow for large dictionaries, what can I do to improve performance?

后端 未结 4 721
滥情空心
滥情空心 2020-12-29 10:22

I am storing a table using python and I need persistence.

Essentially I am storing the table as a dictionary string to numbers. And the whole is stored with shelve

4条回答
  •  一整个雨季
    2020-12-29 10:51

    Based on my experience, I would recommend using SQLite3, which comes with Python. It works well with larger databases and key numbers. Millions of keys and gigabytes of data is not a problem. Shelve is totally wasted at that point. Also having separate db-process isn't beneficial, it just requires more context swaps. In my tests I found out that SQLite3 was the preferred option to use, when handling larger data sets locally. Running local database engine like mongo, mysql or postgresql doesn't provide any additional value and also were slower.

提交回复
热议问题