Does change streams query to DB if config is updateLookup

Hi there,

What really happens to the following code:

ChangeStreamIterable<Document> iterable =

I’m reading this blog and they say:
The events emitted on the stream do not rely on doing any type of query to the database; change streams just filter operations over the oplog.
It seems that Change Streams doesn’t query to the DB.

Change Streams documentation says that:
Set fullDocument to "updateLookup" to direct watch() to look up the most current majority-committed version of the updated document
It seems that Change Streams has to query to the DB.

What really happens?

Just want to clarify a little bit. “query to DB” means that it has to query to another collection other than oplog collection.

Hi @Khanh_Nguyen,

Behind the scene it is utilising an internal interface to build a find command to the collection. Based on MongoDB v5.0.2 code base, I believe this what is being invoked for a non sharded cluster CommonMongodProcessInterface::doLookupSingleDocument()

Please note that to the consumer of change stream events, there is no extra query calls. This is likely what the blog post is referring to, which focus more on usability instead of internal workings.



This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.