问题
I'm inserting just short of 200,000 rows into an sqlite database table. I'm just using a very plain .sql file via sqlite3 in terminal. I'd bet it's been running for at least 30 minutes. Is this normal or should I shut the process down and try something differently?
回答1:
Insert speed in sqlite mainly depends on:
- amount of inserts per transaction (insert without transaction is an atomic insert, each in it's own transaction, which means it's very slow)
- database mode - WAL or normal journal
- number of indexes on the inserted fields
- disk speed
If speed is a problem, then you should consult google for each of those factors I wrote and act appropriately.
回答2:
You should be doing bulk inserts, the kind where you specify the values in a big list, rather than inserting one row at a time. Like this: SQL Bulk Insert statement
来源:https://stackoverflow.com/questions/14787943/sqlite-insert-taking-long-time