Add indexes to temp tables when updating.

The idnexes which are added are for those columns which
are used to calculate information such as latest upstream version.
These queries use subqueries which seemed to be adversely
impacted by the lack of indexes.

In total, reduced update time on test device from just over 100 seconds
to just over 60 seconds.
This commit is contained in:
Peter Serwylo 2015-12-13 18:04:02 +11:00
parent c24cd89028
commit 1ae1ae7368
2 changed files with 6 additions and 0 deletions

View File

@ -123,6 +123,9 @@ public class TempApkProvider extends ApkProvider {
private void initTable() {
write().execSQL("DROP TABLE IF EXISTS " + getTableName());
write().execSQL("CREATE TABLE " + getTableName() + " AS SELECT * FROM " + DBHelper.TABLE_APK);
write().execSQL("CREATE INDEX IF NOT EXISTS apk_vercode on " + getTableName() + " (vercode);");
write().execSQL("CREATE INDEX IF NOT EXISTS apk_id on " + getTableName() + " (id);");
write().execSQL("CREATE INDEX IF NOT EXISTS apk_compatible ON " + getTableName() + " (compatible);");
}
}

View File

@ -114,6 +114,9 @@ public class TempAppProvider extends AppProvider {
private void initTable() {
write().execSQL("DROP TABLE IF EXISTS " + getTableName());
write().execSQL("CREATE TABLE " + getTableName() + " AS SELECT * FROM " + DBHelper.TABLE_APP);
write().execSQL("CREATE INDEX IF NOT EXISTS app_id ON " + getTableName() + " (id);");
write().execSQL("CREATE INDEX IF NOT EXISTS app_upstreamVercode ON " + getTableName() + " (upstreamVercode);");
write().execSQL("CREATE INDEX IF NOT EXISTS app_compatible ON " + getTableName() + " (compatible);");
}
private void commitTable() {