From 2b0890821b8943959a563ec161df26d67cfc0629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= Date: Mon, 20 Feb 2017 10:36:16 +0100 Subject: [PATCH] Switch sort direction of index in order to improve performance --- lib/db.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/db.js b/lib/db.js index a3441bc..4249525 100644 --- a/lib/db.js +++ b/lib/db.js @@ -22,7 +22,7 @@ exports.index = function (collection) { // Ensures there's a reasonable index for the poling dequeue // Status is first b/c querying by status = queued should be very selective - collection.ensureIndex({ status: 1, queue: 1, priority: 1, _id: 1, delay: 1 }, function (err) { + collection.ensureIndex({ status: 1, queue: 1, priority: -1, _id: 1, delay: 1 }, function (err) { if (err) console.error(err); }); };