From d11f069b6076de8b81d8228f76a8cf0012f8ffad Mon Sep 17 00:00:00 2001 From: fmonthel Date: Thu, 17 Nov 2016 21:18:35 -0500 Subject: [ENH] Add index on CardId into Comments collection --- models/cardComments.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/models/cardComments.js b/models/cardComments.js index ce6edf3c..ccad14f7 100644 --- a/models/cardComments.js +++ b/models/cardComments.js @@ -57,6 +57,12 @@ CardComments.helpers({ CardComments.hookOptions.after.update = { fetchPrevious: false }; if (Meteor.isServer) { + // Comments are often fetched within a card, so we create an index to make these + // queries more efficient. + Meteor.startup(() => { + CardComments._collection._ensureIndex({ cardId: 1, createdAt: -1 }); + }); + CardComments.after.insert((userId, doc) => { Activities.insert({ userId, -- cgit v1.2.3-1-g7c22