Or should I use a different hammer to fix this problem.
I\'ve got a very simple use-case for storing data, effectively a sparse matrix, which I\'ve attempted to stor
I've looked at your code, and I think you might be overdoing it with the prepare and finalize statements. I am by no means an SQLite expert, but there's got to be significant overhead in preparing a statement each and every time through the loop.
Quoting from the SQLite website:
After a prepared statement has been evaluated by one or more calls to
sqlite3_step(), it can be reset in order to be evaluated again by a call tosqlite3_reset(). Usingsqlite3_reset()on an existing prepared statement rather creating a new prepared statement avoids unnecessary calls tosqlite3_prepare(). In many SQL statements, the time needed to runsqlite3_prepare()equals or exceeds the time needed bysqlite3_step(). So avoiding calls tosqlite3_prepare()can result in a significant performance improvement.
http://www.sqlite.org/cintro.html
In your case, rather than preparing a new statement each time, you could try binding new values to your existing statement.
All this said, I think the indexes might be the actual culprit, since the time keeps increasing as you add more data. I am curious enough about this where I plan to do some testing over the weekend.