perf(db): enable incremental auto-vacuum so cleared data shrinks the file

This commit is contained in:
zarzet
2026-07-14 09:10:06 +07:00
parent 556399d354
commit 357c684a21
2 changed files with 9 additions and 0 deletions
+5
View File
@@ -796,6 +796,11 @@ class HistoryDatabase {
await txn.delete('history_path_keys');
await txn.delete('history');
});
// Return freed pages to the OS (no-op unless the file was created with
// auto_vacuum enabled).
try {
await db.execute('PRAGMA incremental_vacuum');
} catch (_) {}
_log.i('Cleared all history');
}
+4
View File
@@ -28,6 +28,10 @@ Future<Database> openAppDatabase(
if (foreignKeys) {
await db.execute('PRAGMA foreign_keys = ON');
}
// Without auto_vacuum the file never shrinks after deletes — its size
// is a permanent high-water mark. Only takes effect on newly created
// databases; existing files keep their mode until a manual VACUUM.
await db.execute('PRAGMA auto_vacuum = INCREMENTAL');
await db.rawQuery('PRAGMA journal_mode = WAL');
await db.execute('PRAGMA synchronous = NORMAL');
},