I am new to Android programming, however I am quite used working with SQLite databases.
My application opens a SQLite3 database on the SD card and runs a relatively complex query (5 joins, 1 subquery, 2 where clauses) using SQLiteDatabase.rawQuery
public Cursor queryDataBase(String sql, String[] selectionArgs){
Cursor c = myDB.rawQuery(sql, selectionArgs);
return c;
}
The SQL statement is given by a hardcoded String
.
Steps: 155 , Sorts: 0, AutoIdx: 1077
I am not using primary keys, thus I also didn't rename anything to "_id".
The execution of rawQuery is relatively fast, execution time is about 2 ms.
So what am I missing here? Is it actually possible that my handset with 800 MHz, 2 GB RAM, MicroSD is about 120 times slower?
The execution of rawQuery is relatively fast, execution time is about 2 ms.
Accessing this data takes way too much time, e.g. by c.moveToFirst(), execution time is about 1700 ms! (same for Cursor.getRowCount(), or apparently all first time access to the actual result set).
That's the key: rawQuery does not actually perform the query, but that is delayed until the first time the query results needs to be use.
Source: http://groups.google.com/group/android-developers/browse_thread/thread/c9277225f8dbc4d1/65de841f284f09e6?lnk=gst
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With