Clarification on Oplog Subscription Execution with Specified Fields

Hi Meteor Team,

I have a question regarding how Meteor handles oplog subscriptions for constantly changing data from large collections. Specifically, does Meteor automatically know which subscriptions to execute from the oplog if specific fields are specified at the time of the subscription? If I have too many elements, does it know which element to target to notify the subscription, or does it need to execute every single subscription for each entity in the collection?

Thanks for your help!

It does not “know” it, it has to be checked. Every oplog entry is checked with every observer (think observer = cursor, but it can be deduplicated). The result may be…

  • …“definitely yes”, e.g., { $inc: { a: 1 } } with projection: { a: 1, b: 1 }.
  • …“definitely no”, e.g., { $inc: { c: 1 } } with projection: { a: 1, b: 1 }.
  • …“maybe”, e.g., $inc with $sort and $limit, as the document may change the result (this is slightly more complex, but you get the idea). This one results in a refetch of the cursor (not always, but most of the time).

I’m not sure what do you refer to as “element” here, but once the above detection is done, the oplog entry is “applied”, resulting in zero or more DDP messages sent to the client. It’s done in a smart way, optimized for the lowest possible number of messages (at a cost of server processing time).


Why are you asking exactly? Are you facing some specific problem?

Per field reactivity is possible with redis-oplog

We have an extreme case of a per key of a document, which we make reactive if that document is updated and all subscribed clients are updated.