Skip to content

Build your personal knowledge base with Trilium Notes

faster content hash computation via in memory sorting

zadam620e896a8926
diff --git a/src/services/content_hash.js b/src/services/content_hash.js
index 6946cc33bc..47ae6e5354 100644
--- a/src/services/content_hash.js
+++ b/src/services/content_hash.js
@@ -12,9 +12,11 @@ const RecentNote = require('../entities/recent_note');
const Option = require('../entities/option');
function getSectorHashes(tableName, primaryKeyName, whereBranch) {
- const hashes = sql.getRows(`SELECT ${primaryKeyName} AS id, hash FROM ${tableName} `
- + (whereBranch ? `WHERE ${whereBranch} ` : '')
- + ` ORDER BY ${primaryKeyName}`);
+ const hashes = sql.getRows(`SELECT ${primaryKeyName} AS id, hash FROM ${tableName}`
+ + (whereBranch ? ` WHERE ${whereBranch} ` : ''));
+
+ // sorting is faster in memory
+ hashes.sort((a, b) => a.id < b.id ? -1 : 1);
const map = {};