From 9698fa7e32b741d4dfe8353ab4dbb27fbf8a8716 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Thu, 18 Jul 2013 20:09:39 -0400 Subject: [PATCH] Add an index for a heavy query --- src/com/fsck/k9/mail/store/LocalStore.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/com/fsck/k9/mail/store/LocalStore.java b/src/com/fsck/k9/mail/store/LocalStore.java index a4d0621c2..2294f502d 100644 --- a/src/com/fsck/k9/mail/store/LocalStore.java +++ b/src/com/fsck/k9/mail/store/LocalStore.java @@ -141,7 +141,7 @@ public class LocalStore extends Store implements Serializable { */ 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) { @@ -284,6 +284,11 @@ public class LocalStore extends Store implements Serializable { db.execSQL("DROP INDEX IF EXISTS msg_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("CREATE TABLE threads (" + "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; " + "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);