Android Sqlite Performance

前端 未结 3 1060
遇见更好的自我
遇见更好的自我 2020-12-05 01:33

I have been doing some experiments to measure sqlite performance on android. I was disappointed a little bit with the results. What i did was inserting 10.000 queries to ta

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-05 01:54

    Use SQLite transaction for speed up

    Use BEGIN TRANSACTION & END TRANSACTION for SQLite Optimization

    Each SQL statement is enclosed in a new transaction block by SQLite runtime, by default. Sowhen you perform a basic DB operation such as INSERT, a transaction block will be created and wrapped around it.

    Letting SQLite runtime manage the transaction for you is advisable only if your routine performs only one DB operation on a data set. However, if you are doing numerous DB operations (say INSERT inside for loop), this becomes very expensive, since it requires reopening, writing to, and closing the journal file for each statement. You may refer

    1. Android SQLite database: slow insertion

    2. http://www.androidcode.ninja/android-sqlite-transaction-tutorial/

    3. http://www.techrepublic.com/blog/software-engineer/turbocharge-your-sqlite-inserts-on-android/

    4. http://www.android-app-market.com/sqlite-optimization-in-android-programming-sqlite-optimization-in-android-apps.html

提交回复
热议问题