On publish, does Meteor re-utilize cursors for same query but different fields?


#1

If I return those publication cursors:
Meteor.users.find({});
and
Meteor.users.find({}, {fields: {profile: 1}});

Will Meteor re-utilize it?
Are there any blog post or forum post that I can know more about it?


#2

Calling find() always returns a new cursor. I think you are asking about the observeMultiplexers which try to reduce the overhead of observing the same set of db docs multiple times. They are not reused unless both the selector and the options in the cursor match. This can be seen the mongo_driver code where multiplexers are stored by key which is the collection name, selector, and options as a JSON string.

The Facts package allows you to see this with observe-drivers-polling and observe-drivers-oplog. One of those will get incremented whenever observing a cursor requires a new observe driver.


#3

This is what you need: https://kadira.io/academy/improve-cpu-and-network-usage/


#4

Awesome! Thank you, guys.