浏览代码

- Add Missing Index on cards.parentId since Swimlane integration
to speedup Wekan.

Thanks to Clement87 !

Closes #1863

Lauri Ojansivu 7 年之前
父节点
当前提交
4e12bcc378
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      models/cards.js

+ 6 - 0
models/cards.js

@@ -1017,6 +1017,12 @@ if (Meteor.isServer) {
   // queries more efficient.
   // queries more efficient.
   Meteor.startup(() => {
   Meteor.startup(() => {
     Cards._collection._ensureIndex({boardId: 1, createdAt: -1});
     Cards._collection._ensureIndex({boardId: 1, createdAt: -1});
+    // https://github.com/wekan/wekan/issues/1863
+    // Swimlane added a new field in the cards collection of mongodb named parentId.
+    // When loading a board, mongodb is searching for every cards, the id of the parent (in the swinglanes collection).
+    // With a huge database, this result in a very slow app and high CPU on the mongodb side.
+    // To correct it, add Index to parentId:
+    Cards._collection._ensureIndex({"parentId": 1});
   });
   });
 
 
   Cards.after.insert((userId, doc) => {
   Cards.after.insert((userId, doc) => {