summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/activities.js10
-rw-r--r--models/cards.js6
-rw-r--r--models/lists.js4
3 files changed, 16 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) => {
diff --git a/models/cards.js b/models/cards.js
index aa19a64a..84fbb6c2 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -210,6 +210,12 @@ Cards.mutations({
});
if (Meteor.isServer) {
+ // Cards are often fetched within a board, so we create an index to make these
+ // queries more efficient.
+ Meteor.startup(() => {
+ Cards._collection._ensureIndex({ boardId: 1 });
+ });
+
Cards.after.insert((userId, doc) => {
Activities.insert({
userId,
diff --git a/models/lists.js b/models/lists.js
index a4938f67..9ae2e4f7 100644
--- a/models/lists.js
+++ b/models/lists.js
@@ -91,6 +91,10 @@ Lists.mutations({
Lists.hookOptions.after.update = { fetchPrevious: false };
if (Meteor.isServer) {
+ Meteor.startup(() => {
+ Lists._collection._ensureIndex({ boardId: 1 });
+ });
+
Lists.after.insert((userId, doc) => {
Activities.insert({
userId,