Skip to content

Commit

Permalink
fix: Performance issue on Messages.countByType aggregation (#30062)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman committed Aug 10, 2023
1 parent 6c158b1 commit ea89986
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/brown-clouds-add.md
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fix: Performance issue on `Messages.countByType` aggregation caused by unindexed property on messages collection
2 changes: 1 addition & 1 deletion apps/meteor/ee/app/license/server/getStatistics.ts
Expand Up @@ -101,7 +101,7 @@ async function getEEStatistics(): Promise<EEOnlyStats | undefined> {

statsPms.push(
// Total livechat monitors
Users.col.countDocuments({ type: 'livechat-monitor' }).then((count) => {
Users.col.countDocuments({ roles: 'livechat-monitor' }).then((count) => {
statistics.livechatMonitors = count;
return true;
}),
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/server/models/raw/Messages.ts
Expand Up @@ -77,6 +77,7 @@ export class MessagesRaw extends BaseRaw<IMessage> implements IMessagesModel {
{ key: { 'navigation.token': 1 }, sparse: true },

{ key: { 'federation.eventId': 1 }, sparse: true },
{ key: { t: 1 }, sparse: true },
];
}

Expand Down

0 comments on commit ea89986

Please sign in to comment.