Bad SQLite implementation? The first data access path is too slow

I am new to Android programming, however I am very used to working with SQLite databases.

  • My application opens a SQLite3 database on an SD card and performs a relatively complex query (5 joins, 1 subquery, 2 where clauses) with SQLiteDatabase.rawQuery

    public Cursor queryDataBase(String sql, String[] selectionArgs){
        Cursor c = myDB.rawQuery(sql, selectionArgs);
        return c;
    }
    
  • The SQL statement is defined as hard-coded String.

  • The query returns 585 rows with 24 columns.
  • I had to compromise between memory space and indexing, but all large tables (about 40,000 records currently) use indexes, SQLite shows for the query: Steps: 155 , Sorts: 0, AutoIdx: 1077
  • I do not use primary keys, so I also did not rename anything to "_id".

  • RawQuery execution is relatively fast, 2 ms runtime .

  • Access to this data takes too much time, for example. by c.moveToFirst (), the execution time is 1700 ms! (the same for Cursor.getRowCount () or, apparently, all the first access to the actual result set).
  • Performing the same action on a PC (2 GHz, 1 GB RAM, SATA2 HDD), for example. SQLiteSpy requires 15 ms to display the result set .
  • Performing this on a PC with C ++ implementation, it is also 15 ms to 30 ms .

So what am I missing here? Is it possible that my phone with a frequency of 800 MHz, 2 GB of RAM, MicroSD is about 120 times slower?

+5
2

rawQuery , 2 .

, . by c.moveToFirst(), 1700 ! ( Cursor.getRowCount() , -, ).

: rawQuery , , .

: http://groups.google.com/group/android-developers/browse_thread/thread/c9277225f8dbc4d1/65de841f284f09e6?lnk=gst

+2

, , , .

120 , ( , ), , 9 , "" 8 : 75 .

, , , , .

+1

All Articles