Add an index for a heavy query

This commit is contained in:
Jesse Vincent 2013-07-18 20:09:39 -04:00
parent e8ddf3dbc5
commit 9698fa7e32
1 changed files with 10 additions and 1 deletions

View File

@ -141,7 +141,7 @@ public class LocalStore extends Store implements Serializable {
*/ */
private static final int THREAD_FLAG_UPDATE_BATCH_SIZE = 500; private static final int THREAD_FLAG_UPDATE_BATCH_SIZE = 500;
public static final int DB_VERSION = 48; public static final int DB_VERSION = 49;
public static String getColumnNameForFlag(Flag flag) { public static String getColumnNameForFlag(Flag flag) {
@ -284,6 +284,11 @@ public class LocalStore extends Store implements Serializable {
db.execSQL("DROP INDEX IF EXISTS msg_flagged"); db.execSQL("DROP INDEX IF EXISTS msg_flagged");
db.execSQL("CREATE INDEX IF NOT EXISTS msg_flagged ON messages (flagged)"); db.execSQL("CREATE INDEX IF NOT EXISTS msg_flagged ON messages (flagged)");
db.execSQL("DROP INDEX IF EXISTS msg_composite");
db.execSQL("CREATE INDEX IF NOT EXISTS msg_composite ON messages (deleted, empty,folder_id,flagged,read)");
db.execSQL("DROP TABLE IF EXISTS threads"); db.execSQL("DROP TABLE IF EXISTS threads");
db.execSQL("CREATE TABLE threads (" + db.execSQL("CREATE TABLE threads (" +
"id INTEGER PRIMARY KEY, " + "id INTEGER PRIMARY KEY, " +
@ -689,6 +694,10 @@ public class LocalStore extends Store implements Serializable {
"UPDATE threads SET root=id WHERE root IS NULL AND ROWID = NEW.ROWID; " + "UPDATE threads SET root=id WHERE root IS NULL AND ROWID = NEW.ROWID; " +
"END"); "END");
} }
if (db.getVersion() < 49) {
db.execSQL("CREATE INDEX IF NOT EXISTS msg_composite ON messages (deleted, empty,folder_id,flagged,read)");
}
} }
db.setVersion(DB_VERSION); db.setVersion(DB_VERSION);