〜90000行のテーブルを持つSQLiteデータベースがあります.これは、完了するのに時間がかかりすぎる方法です..
void intilizeAyaHighlighShapes() {
ayaShapes = new ArrayList<ArrayList<AyaShape>>();
ArrayList<AyaShape> ayaRowsHighlight = new ArrayList<AyaShape>(); // contains the highligh shapes of a specific aya for all its rows
int tmpAya = 1, tmpLineMin = 0, tmpLineMax = 0;
int maxLeft = 0, maxRight = 0, maxTop = 0, maxBottom = 0;
SQLiteDatabase db = SQLiteDatabase.openDatabase(Environment.getExternalStorageDirectory() + "/ayahinfo_800.db", null, SQLiteDatabase.OPEN_READONLY);
Cursor cursor = null;
while (tmpAya < Database.AyatNumberInSura[suraIndex]) {
cursor = db.rawQuery("SELECT MIN(line_number) FROM glyphs WHERE(sura_number=" + Integer.toString(suraIndex + 1) + " AND ayah_number=" + Integer.toString(tmpAya) + ")",
null);
cursor.moveToFirst();
tmpLineMin = cursor.getInt(0);
cursor = db.rawQuery("SELECT MAX(line_number) FROM glyphs WHERE(sura_number=" + Integer.toString(suraIndex + 1) + " AND ayah_number=" + Integer.toString(tmpAya) + ")",
null);
cursor.moveToFirst();
tmpLineMax = cursor.getInt(0);
for (int i = tmpLineMin; i <= tmpLineMax; i++) {
cursor = db.rawQuery("SELECT MAX(max_x) FROM glyphs WHERE (sura_number=" + Integer.toString(suraIndex + 1) + " AND ayah_number=" + Integer.toString(tmpAya)
+ " AND line_number=" + Integer.toString(i) + ")", null);
cursor.moveToFirst();
maxRight = cursor.getInt(0);
cursor = db.rawQuery("SELECT MIN(min_x) FROM glyphs WHERE (sura_number=" + Integer.toString(suraIndex + 1) + " AND ayah_number=" + Integer.toString(tmpAya)
+ " AND line_number=" + Integer.toString(i) + ")", null);
cursor.moveToFirst();
maxLeft = cursor.getInt(0);
cursor = db.rawQuery("SELECT MAX(max_y) FROM glyphs WHERE (sura_number=" + Integer.toString(suraIndex + 1) + " AND ayah_number=" + Integer.toString(tmpAya)
+ " AND line_number=" + Integer.toString(i) + ")", null);
cursor.moveToFirst();
maxBottom = cursor.getInt(0);
cursor = db.rawQuery("SELECT MIN(min_y) FROM glyphs WHERE (sura_number=" + Integer.toString(suraIndex + 1) + " AND ayah_number=" + Integer.toString(tmpAya)
+ " AND line_number=" + Integer.toString(i) + ")", null);
cursor.moveToFirst();
maxTop = cursor.getInt(0);
ayaRowsHighlight.add(new AyaShape(maxLeft, maxRight, maxTop, maxBottom));
}
ayaShapes.add(ayaRowsHighlight);
ayaRowsHighlight.clear();
tmpAya++;
}
cursor.close();
db.close();
}
このコードのどの部分が非常に時間がかかる原因になっている可能性がありますか?
このコードの目的をここに書く必要がありますか?