Android SQLite database: slow insertion -
i need parse big xml file (varying between hundred kilobytes , several hundred kilobytes), i'm doing using xml#parse(string, contenthandler)
. i'm testing 152kb file.
during parsing, insert info in sqlite database using calls similar following: getwritabledatabase().insert(table_name, "_id", values)
. of takes 80 seconds 152kb test file (which comes downwards inserting 200 rows).
when comment out insert statements (but leave in else, such creating contentvalues
etc.) same file takes 23 seconds.
is normal database operations have such big overhead? can that?
you should batch inserts.
pseudocode:
db.begintransaction(); (entry : listofentries) { db.insert(entry); } db.settransactionsuccessful(); db.endtransaction();
that increased speed of inserts in apps extremely.
update: @yuku provided interesting blog post: android using inserthelper faster insertions sqlite database
android database performance sqlite insert
No comments:
Post a Comment