Add index to improve speed of MMS count.

This commit is contained in:
Greyson Parrelli
2022-03-15 18:49:17 -04:00
committed by Cody Henthorne
parent 172751cd42
commit 130d5a8945
2 changed files with 7 additions and 1 deletions

View File

@@ -191,7 +191,8 @@ public class MmsDatabase extends MessageDatabase {
"CREATE INDEX IF NOT EXISTS mms_thread_date_index ON " + TABLE_NAME + " (" + THREAD_ID + ", " + DATE_RECEIVED + ");",
"CREATE INDEX IF NOT EXISTS mms_reactions_unread_index ON " + TABLE_NAME + " (" + REACTIONS_UNREAD + ");",
"CREATE INDEX IF NOT EXISTS mms_is_story_index ON " + TABLE_NAME + " (" + STORY_TYPE + ");",
"CREATE INDEX IF NOT EXISTS mms_parent_story_id_index ON " + TABLE_NAME + " (" + PARENT_STORY_ID + ");"
"CREATE INDEX IF NOT EXISTS mms_parent_story_id_index ON " + TABLE_NAME + " (" + PARENT_STORY_ID + ");",
"CREATE INDEX IF NOT EXISTS mms_thread_story_parent_story_index ON " + TABLE_NAME + " (" + THREAD_ID + ", " + DATE_RECEIVED + "," + STORY_TYPE + "," + PARENT_STORY_ID + ");",
};
private static final String[] MMS_PROJECTION = new String[] {

View File

@@ -194,6 +194,7 @@ object SignalDatabaseMigrations {
private const val STORIES = 132
private const val ALLOW_STORY_REPLIES = 133
private const val GROUP_STORIES = 134
private const val MMS_COUNT_INDEX = 135
const val DATABASE_VERSION = 135
@@ -2481,6 +2482,10 @@ object SignalDatabaseMigrations {
if (oldVersion < GROUP_STORIES) {
db.execSQL("ALTER TABLE groups ADD COLUMN display_as_story INTEGER DEFAULT 0")
}
if (oldVersion < MMS_COUNT_INDEX) {
db.execSQL("CREATE INDEX IF NOT EXISTS mms_thread_story_parent_story_index ON mms (thread_id, date_received, is_story, parent_story_id)")
}
}
@JvmStatic