Inserting to Sqlite is slow

This question already has an answer here:

  • Improve INSERT-per-second performance of SQLite? 10 answers

  • Its slow because you are firing 22000 queries to the database. You should insert in batches. That will fix the problem. Even if a single insert takes 10ms total time is like 3.5 minutes!!

    A simple insert query with batches of 2 will look like this

    "INSERT INTO WORD (word) VALUES ("+"'"+s.get(i)+"'"+"), ("+"'"+s.get(i+1)+"'"+");";
    

    This will reduce the time by half. Now you will have to programatically insert more of these values.

    链接地址: http://www.djcxy.com/p/19774.html

    上一篇: 如何批量插入或更新在SQLite的Android?

    下一篇: 插入到Sqlite很慢