diff --git a/src/services/content_hash.js b/src/services/content_hash.js index 6946cc33b..47ae6e535 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 = {};