R.Alvin
R.Alvin

Reputation: 89

sqlite insert taking long time

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?

Upvotes: 2

Views: 2888

Answers (2)

Dariusz
Dariusz

Reputation: 22291

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.

Upvotes: 4

John Zwinck
John Zwinck

Reputation: 249592

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

Upvotes: 0

Related Questions