How to watch Meteor's interactions with MongoDB?

Hi,

My problem: a single Collection.update() is causing 5-7 queries to MongoDB

I discovered this by chance, because I have turned on System Profiling locally:

$ meteor mongo

MongoDB shell version: 3.2.15
connecting to: 127.0.0.1:3001/meteor

meteor:PRIMARY> db.setProfilingLevel(2)
{ “was” : 0, “slowms” : 100, “ok” : 1 }

My code looks something like this:

Collection.update(
        {
          _id: documentId,
        },
        {
          $addToSet: {
            likedBy: this.userId,
          },
        },
      );

This results in 7 queries: 1 updateObj query, and 7 read queries.

If I use Collection.direct.update, then 2 of the read queries disappear.

I have a couple of theories for as to who’s generating the reads, but would be nice to have tracking tool.

Is there anything in Meteor that would allow me to pinpoint exactly where any kind of query is coming from?

This is what a server side method looks like in Monti APM. I don’t use pub/sub or client side methods but I guess they would be similar and Monti might provide you the right understanding of what is going on.

You can see in-flight MongoDB queries etc stats with NoSQLBooster

MongoDB backend

MiniMongo

At browser right click inspect / Meteor