mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01:00
Add MongoDB indexes
These indexes will optimize the queries that are used in the board and card views. Fixes #524.
This commit is contained in:
parent
81a35be856
commit
9792193e60
3 changed files with 16 additions and 4 deletions
|
|
@ -41,12 +41,14 @@ Activities.before.insert((userId, doc) => {
|
||||||
doc.createdAt = new Date();
|
doc.createdAt = new Date();
|
||||||
});
|
});
|
||||||
|
|
||||||
// For efficiency create an index on the date of creation.
|
|
||||||
if (Meteor.isServer) {
|
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(() => {
|
Meteor.startup(() => {
|
||||||
Activities._collection._ensureIndex({
|
Activities._collection._ensureIndex({ createdAt: -1 });
|
||||||
createdAt: -1,
|
Activities._collection._ensureIndex({ cardId: 1, createdAt: -1 });
|
||||||
});
|
Activities._collection._ensureIndex({ boardId: 1, createdAt: -1 });
|
||||||
});
|
});
|
||||||
|
|
||||||
Activities.after.insert((userId, doc) => {
|
Activities.after.insert((userId, doc) => {
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,12 @@ Cards.mutations({
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Meteor.isServer) {
|
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) => {
|
Cards.after.insert((userId, doc) => {
|
||||||
Activities.insert({
|
Activities.insert({
|
||||||
userId,
|
userId,
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,10 @@ Lists.mutations({
|
||||||
Lists.hookOptions.after.update = { fetchPrevious: false };
|
Lists.hookOptions.after.update = { fetchPrevious: false };
|
||||||
|
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
|
Meteor.startup(() => {
|
||||||
|
Lists._collection._ensureIndex({ boardId: 1 });
|
||||||
|
});
|
||||||
|
|
||||||
Lists.after.insert((userId, doc) => {
|
Lists.after.insert((userId, doc) => {
|
||||||
Activities.insert({
|
Activities.insert({
|
||||||
userId,
|
userId,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue