summaryrefslogtreecommitdiffstats
path: root/models/activities.js
diff options
context:
space:
mode:
authorMaxime Quandalle <mquandalle@wekan.io>2016-07-18 22:38:38 +0200
committerMaxime Quandalle <mquandalle@wekan.io>2016-07-18 22:38:38 +0200
commit9792193e605a8df8989c36e1e4edad25464aa442 (patch)
tree248750df6e619afc20c4fdc848da63a3d3c526a3 /models/activities.js
parent81a35be8562cb6c28848afc2cb24ae9ec145ce47 (diff)
downloadwekan-9792193e605a8df8989c36e1e4edad25464aa442.tar.gz
wekan-9792193e605a8df8989c36e1e4edad25464aa442.tar.bz2
wekan-9792193e605a8df8989c36e1e4edad25464aa442.zip
Add MongoDB indexes
These indexes will optimize the queries that are used in the board and card views. Fixes #524.
Diffstat (limited to 'models/activities.js')
-rw-r--r--models/activities.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/models/activities.js b/models/activities.js
index ad920149..aa2ea3ec 100644
--- a/models/activities.js
+++ b/models/activities.js
@@ -41,12 +41,14 @@ Activities.before.insert((userId, doc) => {
doc.createdAt = new Date();
});
-// For efficiency create an index on the date of creation.
if (Meteor.isServer) {
+ // For efficiency create indexes on the date of creation, and on the date of
+ // creation in conjunction with the card or board id, as corresponding views
+ // are largely used in the App. See #524.
Meteor.startup(() => {
- Activities._collection._ensureIndex({
- createdAt: -1,
- });
+ Activities._collection._ensureIndex({ createdAt: -1 });
+ Activities._collection._ensureIndex({ cardId: 1, createdAt: -1 });
+ Activities._collection._ensureIndex({ boardId: 1, createdAt: -1 });
});
Activities.after.insert((userId, doc) => {