add indices on blobId

This commit is contained in:
zadam 2023-07-27 21:40:47 +02:00
parent 5b0f487f3f
commit 527718eff7
6 changed files with 449 additions and 647 deletions

View File

@ -0,0 +1,3 @@
CREATE INDEX IDX_notes_blobId on notes (blobId);
CREATE INDEX IDX_revisions_blobId on revisions (blobId);
CREATE INDEX IDX_attachments_blobId on attachments (blobId);

View File

@ -128,3 +128,7 @@ CREATE TABLE IF NOT EXISTS "attachments"
deleteId TEXT DEFAULT NULL); deleteId TEXT DEFAULT NULL);
CREATE INDEX IDX_attachments_ownerId_role CREATE INDEX IDX_attachments_ownerId_role
on attachments (ownerId, role); on attachments (ownerId, role);
CREATE INDEX IDX_notes_blobId on notes (blobId);
CREATE INDEX IDX_revisions_blobId on revisions (blobId);
CREATE INDEX IDX_attachments_blobId on attachments (blobId);

1067
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -53,7 +53,7 @@
"escape-html": "1.0.3", "escape-html": "1.0.3",
"express": "4.18.2", "express": "4.18.2",
"express-partial-content": "1.0.2", "express-partial-content": "1.0.2",
"express-rate-limit": "6.8.0", "express-rate-limit": "6.8.1",
"express-session": "1.17.3", "express-session": "1.17.3",
"fs-extra": "11.1.1", "fs-extra": "11.1.1",
"helmet": "7.0.0", "helmet": "7.0.0",
@ -65,10 +65,10 @@
"ini": "3.0.1", "ini": "3.0.1",
"is-animated": "2.0.2", "is-animated": "2.0.2",
"is-svg": "4.3.2", "is-svg": "4.3.2",
"jimp": "0.22.8", "jimp": "0.22.10",
"joplin-turndown-plugin-gfm": "1.0.12", "joplin-turndown-plugin-gfm": "1.0.12",
"jsdom": "22.1.0", "jsdom": "22.1.0",
"marked": "5.1.1", "marked": "5.1.2",
"mime-types": "2.1.35", "mime-types": "2.1.35",
"multer": "1.4.5-lts.1", "multer": "1.4.5-lts.1",
"node-abi": "3.45.0", "node-abi": "3.45.0",
@ -92,24 +92,24 @@
"turndown": "7.1.2", "turndown": "7.1.2",
"unescape": "1.0.1", "unescape": "1.0.1",
"ws": "8.13.0", "ws": "8.13.0",
"xml2js": "0.6.0", "xml2js": "0.6.2",
"yauzl": "2.10.0" "yauzl": "2.10.0"
}, },
"devDependencies": { "devDependencies": {
"cross-env": "7.0.3", "cross-env": "7.0.3",
"electron": "25.3.1", "electron": "25.3.2",
"electron-builder": "24.4.0", "electron-builder": "24.6.3",
"electron-packager": "17.1.1", "electron-packager": "17.1.1",
"electron-rebuild": "3.2.9", "electron-rebuild": "3.2.9",
"eslint": "8.45.0", "eslint": "8.45.0",
"eslint-config-airbnb-base": "15.0.0", "eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "8.8.0", "eslint-config-prettier": "8.9.0",
"eslint-plugin-import": "2.27.5", "eslint-plugin-import": "2.27.5",
"eslint-plugin-jsonc": "2.9.0", "eslint-plugin-jsonc": "2.9.0",
"eslint-plugin-prettier": "5.0.0", "eslint-plugin-prettier": "5.0.0",
"esm": "3.2.25", "esm": "3.2.25",
"husky": "8.0.3", "husky": "8.0.3",
"jasmine": "5.0.2", "jasmine": "5.1.0",
"jsdoc": "4.0.2", "jsdoc": "4.0.2",
"jsonc-eslint-parser": "2.3.0", "jsonc-eslint-parser": "2.3.0",
"lint-staged": "13.2.3", "lint-staged": "13.2.3",

View File

@ -156,13 +156,13 @@ class AbstractBeccaEntity {
this.save(); this.save();
if (newBlobId !== oldBlobId) { if (newBlobId !== oldBlobId) {
this.#deleteBlobIfNoteUsed(oldBlobId); this.#deleteBlobIfNotUsed(oldBlobId);
} }
} }
}); });
} }
#deleteBlobIfNoteUsed(blobId) { #deleteBlobIfNotUsed(blobId) {
if (sql.getValue("SELECT 1 FROM notes WHERE blobId = ? LIMIT 1", [blobId])) { if (sql.getValue("SELECT 1 FROM notes WHERE blobId = ? LIMIT 1", [blobId])) {
return; return;
} }

View File

@ -4,7 +4,7 @@ const build = require('./build');
const packageJson = require('../../package'); const packageJson = require('../../package');
const {TRILIUM_DATA_DIR} = require('./data_dir'); const {TRILIUM_DATA_DIR} = require('./data_dir');
const APP_DB_VERSION = 222; const APP_DB_VERSION = 223;
const SYNC_VERSION = 30; const SYNC_VERSION = 30;
const CLIPPER_PROTOCOL_VERSION = "1.0"; const CLIPPER_PROTOCOL_VERSION = "1.0";