【发布时间】:2023-03-24 15:26:02
【问题描述】:
我正在使用以下几行来循环 Sqlite 查询的行。
this.open(); // opening db
Cursor cursor = db.rawQuery(strQuery, null);
cursor.moveToFirst();
do {
// do something
} while (cursor.moveToNext());
cursor.close();
当行数约为 15000 时,需要很长时间。 空的while 块大约需要 4 秒,带有一些代码的 while 块大约需要 6 秒。它表明以这种方式对行进行迭代非常耗时。
有没有更快的方法在 android 和 Sqlite 中的行上循环?
谢谢,
【问题讨论】:
-
我不确定您的 SQLite 用例,但这可能有用:shopwith.it/2011/12/16/…
-
如果你愿意,你能解释一下为什么你需要一次检索这么多记录吗?你也不能在你的 SELECT 语句中折叠到更少吗?
标签: java android sqlite android-cursor