mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-31 19:41:19 +00:00
Added checkpointing (debug version)
This commit is contained in:
parent
cb70edab35
commit
6ce301426d
2 changed files with 25 additions and 0 deletions
|
@ -29,6 +29,7 @@ import org.json.JSONObject;
|
|||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -1856,6 +1857,28 @@ public abstract class DB extends RoomDatabase {
|
|||
});
|
||||
}
|
||||
|
||||
public void checkpoint(Context context) {
|
||||
if (!BuildConfig.DEBUG)
|
||||
return;
|
||||
|
||||
// https://www.sqlite.org/pragma.html#pragma_wal_checkpoint
|
||||
long start = new Date().getTime();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
SupportSQLiteDatabase db = getInstance(context).getOpenHelper().getWritableDatabase();
|
||||
try (Cursor cursor = db.query("PRAGMA wal_checkpoint(PASSIVE);")) {
|
||||
if (cursor.moveToNext()) {
|
||||
for (int i = 0; i < cursor.getColumnCount(); i++) {
|
||||
if (i > 0)
|
||||
sb.append(",");
|
||||
sb.append(cursor.getInt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
long elapse = new Date().getTime() - start;
|
||||
Log.i("PRAGMA wal_checkpoint=" + sb + " elapse=" + elapse);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void beginTransaction() {
|
||||
|
|
|
@ -62,6 +62,8 @@ public class WorkerFts extends Worker {
|
|||
int indexed = 0;
|
||||
List<Long> ids = new ArrayList<>(INDEX_BATCH_SIZE);
|
||||
DB db = DB.getInstance(context);
|
||||
db.checkpoint(context);
|
||||
|
||||
SQLiteDatabase sdb = FtsDbHelper.getInstance(context);
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
try (Cursor cursor = db.message().getMessageFts()) {
|
||||
|
|
Loading…
Reference in a new issue