From ab5123d90330f6fbcffb7bed5b162d6526dbdc66 Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Thu, 22 Dec 2022 14:51:57 +0000 Subject: [PATCH] feat: better indexes for performance --- server/src/external/mongo/indexes.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/src/external/mongo/indexes.ts b/server/src/external/mongo/indexes.ts index 3f8cd699d..0703332b5 100644 --- a/server/src/external/mongo/indexes.ts +++ b/server/src/external/mongo/indexes.ts @@ -27,13 +27,20 @@ const staticIndexes: Partial>> = { index({ scoreID: 1 }, UNIQUE), index({ chartID: 1, userID: 1 }), index({ userID: 1, game: 1, playtype: 1 }), + + // activity + index({ game: 1, playtype: 1, highlight: 1, timeAchieved: 1 }), ], "personal-bests": [ index({ chartID: 1, userID: 1 }, UNIQUE), index({ chartID: 1, "scoreData.percent": 1 }), index({ userID: 1, game: 1, playtype: 1 }), + + // activity + index({ game: 1, playtype: 1, timeAchieved: 1 }), ], sessions: [ + index({ game: 1, playtype: 1, timeStarted: 1 }), index({ userID: 1, game: 1, playtype: 1, timeStarted: 1, timeEnded: 1 }), // Optimises score modification, since sessions need to be repointed.