I found that I had to significantly restructure both my database design and query sequences in order to get satisfactory performance on an actual phone. There are big differences between Android and a PC, such as lack of gobs of real (and virtual!) memory. You don't have a database server that can do things like cache indices, etc. I also put my query work into an AsyncTask to keep from stalling the UI, but even so when I took a PC-like approach to my queries the busy-dialog was up there way too long.
You really have to optimize everything. Doug Gordon On Dec 8, 3: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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en