Search code examples
androidsqliteindexingandroid-2.2-froyoandroid-2.3-gingerbread

Android sqlite index on android 2.3


I have two device: HTC Desire with Android 2.2 Froyo and HTC Evo 3D with Android 2.3 Gingerbread.

My sql request:

SELECT DISTINCT Album.titre, Serie.nbAlbum 
  FROM Serie, Album 
  WHERE Serie.titre=Album.serieTitre AND Album.shz=1 

with a non-indexed database :

htc evo 3d : Everything works fine, the query runs in ~1 second.
htc desire : This is much longer! about 30 - 50 seconds.

So, i tried to index my table with :

CREATE INDEX IDX_ALBUM_SHZ on ALBUM (shz)
CREATE INDEX IDX_ALBUM_SERIETITRE on ALBUM(serieTitre)

but the result were reversed!

HTC Desire : Really fast, ~1 second.
HTC Evo 3d : Very slow, more than 20 seconds

Have you an idea of ​​what's happening?
It is there was a significant change in how to manage sqlite between froyo and gingerbread?

How to solve this problem?


Solution

  • If no solution, I solved my problem with a simple check of version at the database creation / import, and add / remove indexes accordingly.

    However, I remain open to a smarter!