Thursday, December 9, 2010

[android-developers] Re: Poor SQLite implementation? first time data access way to slow

On a previous generation of smartphone hardware, a 1msec difference in
db access on an UML [User Mode Linux] emulator turned into a whole
second difference on a "Zylonite" board. So a 120x difference between
desktop hardware with a hard disk and an Android device with flash
memory doesn't seem at all implausible.

On Dec 8, 12:49 pm, carbi84 <leistner.d...@googlemail.com> wrote:
> Hi there,
>
> 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
> kinda 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
> - the query returns 585 rows with 24 columns
> - i had to do a trade-off between storage space and indexing, but on
> all bigger tables (about ~ 40 000 entries, for now) indexes are used,
> SQLite shows for the query: 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 kinda fast, execution time is about 2
> ms
> - however accessing this data takes way too much time, e.g. by
> c.moveToFirst(), execution time about 1700 ms ! (same for
> Cursor.getRowCount(), or apparently all first time access to the
> actual result set)
> - doing the same on a PC ( 2 Ghz, 1 GB RAM) with e.g. SQLiteSpy it
> takes 15 ms to display the result set
> - doing it on the PC with a C++ Implementation it's also 15 ms up to
> 30 ms
>
> So what am i missing here? Is it actually possible that my Handset
> with 800 MHz and 2 GB RAM is about 120 times slower??
>
> ( of course i am also aware of the speed difference between a microSD
> card and a sata2 hdd, but that shouldn't explain this huge difference,
> right? )

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment