瀏覽代碼

Merge branch 'maulal-devel' into devel
Improve Wekan performance by adding indexes to MongoDB

Lauri Ojansivu 8 年之前
父節點
當前提交
b4fd6b7004
共有 5 個文件被更改,包括 11 次插入1 次删除
  1. 2 0
      models/activities.js
  2. 1 0
      models/boards.js
  3. 1 1
      models/cards.js
  4. 4 0
      models/checklists.js
  5. 3 0
      models/unsavedEdits.js

+ 2 - 0
models/activities.js

@@ -52,6 +52,8 @@ if (Meteor.isServer) {
     Activities._collection._ensureIndex({ createdAt: -1 });
     Activities._collection._ensureIndex({ cardId: 1, createdAt: -1 });
     Activities._collection._ensureIndex({ boardId: 1, createdAt: -1 });
+    Activities._collection._ensureIndex({ commentId: 1 }, { partialFilterExpression: { commentId: { $exists: true } } });
+    Activities._collection._ensureIndex({ attachmentId: 1 }, { partialFilterExpression: { attachmentId: { $exists: true } } });
   });
 
   Activities.after.insert((userId, doc) => {

+ 1 - 0
models/boards.js

@@ -414,6 +414,7 @@ if (Meteor.isServer) {
       _id: 1,
       'members.userId': 1,
     }, { unique: true });
+    Boards._collection._ensureIndex({'members.userId': 1});
   });
 
   // Genesis: the first activity of the newly created board

+ 1 - 1
models/cards.js

@@ -267,7 +267,7 @@ 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._collection._ensureIndex({ boardId: 1, createdAt: -1 });
   });
 
   Cards.after.insert((userId, doc) => {

+ 4 - 0
models/checklists.js

@@ -133,6 +133,10 @@ Checklists.mutations({
 });
 
 if (Meteor.isServer) {
+  Meteor.startup(() => {
+    Checklists._collection._ensureIndex({ cardId: 1, createdAt: 1 });
+  });
+
   Checklists.after.insert((userId, doc) => {
     Activities.insert({
       userId,

+ 3 - 0
models/unsavedEdits.js

@@ -26,6 +26,9 @@ if (Meteor.isServer) {
   function isAuthor(userId, doc, fieldNames = []) {
     return userId === doc.userId && fieldNames.indexOf('userId') === -1;
   }
+  Meteor.startup(() => {
+    UnsavedEditCollection._collection._ensureIndex({ userId: 1 });
+  });
   UnsavedEditCollection.allow({
     insert: isAuthor,
     update: isAuthor,