Long response times for "ObserveChanges" | Meteor js

I download a test application for the main chat and notice in Qadir that about 286ms was spent on "ObserveChanges" by subscription.

Kadira

The roomDetail subscription uses the roomId parameter to find all Message documents with a matching roomId and looks like this:

Meteor.publish('roomDetail', function(roomId) {
    return Messages.find({roomId: roomId}, {limit: 100, sort: { submitted : -1 }});
});

      

I am wondering how I can reduce the response time for "watchChanges" here. I have already added an index to the Messages collection:

Messages = new Mongo.Collection ('messages');

if (Meteor.isServer) {
    // Index on roomid and reverse date order
    Messages._ensureIndex({roomId: 1, submitted: -1});
}

      

But I don't think it will help me with high response times for "watchChanges".

Any ideas on how I can best shorten the response time? Am I not following certain guidelines here?

+3


source to share


1 answer


I think MongoDB index roomId

won't help. There is no official way to automatically do this from within the app, but you could a) just do it from the Mongo console, or b) I seem to remember that there is some way to get to the default MongoDB Node driver from the Meteor collection with which you could create an index.



0


source







All Articles