Skip to content

Commit

Permalink
[Experiment] Use incremental vacuum to speed up delete? (#2800)
Browse files Browse the repository at this point in the history
* DB: Use incremental vacuum

* Chore: Add log for delete monitor exec. time

* WIP: Test synchronous NORMAL
  • Loading branch information
chakflying authored Jun 29, 2023
1 parent eaee55f commit a386f1f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ class Database {
await R.exec("PRAGMA journal_mode = WAL");
}
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.
// FULL synchronous is very safe, but it is also slower.
// Read more: https://sqlite.org/pragma.html#pragma_synchronous
await R.exec("PRAGMA synchronous = FULL");
await R.exec("PRAGMA synchronous = NORMAL");

if (!noLog) {
log.info("db", "SQLite config:");
Expand Down
6 changes: 6 additions & 0 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,8 @@ let needSetup = false;
delete server.monitorList[monitorID];
}

const startTime = Date.now();

await R.exec("DELETE FROM monitor WHERE id = ? AND user_id = ? ", [
monitorID,
socket.userID,
Expand All @@ -910,6 +912,10 @@ let needSetup = false;
// Fix #2880
apicache.clear();

const endTime = Date.now();

log.info("DB", `Delete Monitor completed in : ${endTime - startTime} ms`);

This comment has been minimized.

Copy link
@Saibamen

Saibamen Jun 30, 2023

Contributor

in:


callback({
ok: true,
msg: "Deleted Successfully.",
Expand Down

0 comments on commit a386f1f

Please sign in to comment.