Android does not execute the query until you try to use the Cursor, so your 1700ms is when the actual query is being executed.
Your handset does not have 2GB of RAM. It may not have a tenth of that. On Wed, Dec 8, 2010 at 3:49 PM, carbi84 <[email protected]> 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? ) -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

