mercredi 23 mars 2016

Android sqlite UPDATE efficiency is low

My problem seems wired.

I have a sqlite database when contains about 2500 rows. When I execute the following:

ContentValues values = new ContentValues();
values.put(column, 0);
db.update(table, values, null, null);

It costs 3 seconds on average before finishing.

I also tried

db.execSQL("UPDATE table SET column = 0");

Even longer.

Here is the .stat info I got when I executed same command on PC:

sqlite> .stat on
sqlite> UPDATE table SET column = 0;
Memory Used:                         10322672 (max 12336272) bytes
Number of Outstanding Allocations:   2229 (max 2529)
Number of Pcache Overflow Bytes:     10237952 (max 10243072) bytes
Number of Scratch Overflow Bytes:    0 (max 0) bytes
Largest Allocation:                  797509 bytes
Largest Pcache Allocation:           4248 bytes
Largest Scratch Allocation:          0 bytes
Lookaside Slots Used:                16 (max 56)
Successful lookaside attempts:       155
Lookaside failures due to size:      190
Lookaside failures due to OOM:       0
Pager Heap Usage:                    8468392 bytes
Page cache hits:                     87018
Page cache misses:                   16596
Page cache writes:                   13201
Schema Heap Usage:                   5088 bytes
Statement Heap/Lookaside Usage:      2656 bytes
Fullscan Steps:                      2584
Sort Operations:                     0
Autoindex Inserts:                   0
Virtual Machine Steps:               67221

Can anyone help me figure out where the problem is and how to solve it ?

Aucun commentaire:

Enregistrer un commentaire