[Experiment] Use incremental vacuum to speed up delete? (#2800)
* DB: Use incremental vacuum * Chore: Add log for delete monitor exec. time * WIP: Test synchronous NORMAL
This commit is contained in:
parent
eaee55fc8f
commit
a386f1fc9e
|
@ -169,12 +169,12 @@ class Database {
|
||||||
await R.exec("PRAGMA journal_mode = WAL");
|
await R.exec("PRAGMA journal_mode = WAL");
|
||||||
}
|
}
|
||||||
await R.exec("PRAGMA cache_size = -12000");
|
await R.exec("PRAGMA cache_size = -12000");
|
||||||
await R.exec("PRAGMA auto_vacuum = FULL");
|
await R.exec("PRAGMA auto_vacuum = INCREMENTAL");
|
||||||
|
|
||||||
// This ensures that an operating system crash or power failure will not corrupt the database.
|
// This ensures that an operating system crash or power failure will not corrupt the database.
|
||||||
// FULL synchronous is very safe, but it is also slower.
|
// FULL synchronous is very safe, but it is also slower.
|
||||||
// Read more: https://sqlite.org/pragma.html#pragma_synchronous
|
// Read more: https://sqlite.org/pragma.html#pragma_synchronous
|
||||||
await R.exec("PRAGMA synchronous = FULL");
|
await R.exec("PRAGMA synchronous = NORMAL");
|
||||||
|
|
||||||
if (!noLog) {
|
if (!noLog) {
|
||||||
log.info("db", "SQLite config:");
|
log.info("db", "SQLite config:");
|
||||||
|
|
|
@ -902,6 +902,8 @@ let needSetup = false;
|
||||||
delete server.monitorList[monitorID];
|
delete server.monitorList[monitorID];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const startTime = Date.now();
|
||||||
|
|
||||||
await R.exec("DELETE FROM monitor WHERE id = ? AND user_id = ? ", [
|
await R.exec("DELETE FROM monitor WHERE id = ? AND user_id = ? ", [
|
||||||
monitorID,
|
monitorID,
|
||||||
socket.userID,
|
socket.userID,
|
||||||
|
@ -910,6 +912,10 @@ let needSetup = false;
|
||||||
// Fix #2880
|
// Fix #2880
|
||||||
apicache.clear();
|
apicache.clear();
|
||||||
|
|
||||||
|
const endTime = Date.now();
|
||||||
|
|
||||||
|
log.info("DB", `Delete Monitor completed in : ${endTime - startTime} ms`);
|
||||||
|
|
||||||
callback({
|
callback({
|
||||||
ok: true,
|
ok: true,
|
||||||
msg: "Deleted Successfully.",
|
msg: "Deleted Successfully.",
|
||||||
|
|
Loading…
Reference in New Issue