Hi all. I have a question or two about the mongodb
lookup aggregation performance.
Using this aggregation to lookup from another collection, I found through testing that indexing the field used of the collection being joined on (the
foreignField
field in the lookup request) can improve performance a lot. Note that I couldnt find any documentation to confirm this although practically it makes a huge difference in my query (if there are any docs that confirms this, please let me know!).
Now, for 3.6 they have also added "pipeline" field which, if specified, is ran on the joined collection. This pipline can contain match and projection stages, maybe even more.
My questions is: if specifying the pipeline in the lookup aggregation, will the indexes defined for the joined collection be used when processing this pipeline? It would be great if I can create a covered query inside this lookup pipeline by using the correct match & project stages (which should result in better performance than when only matching/projecting after the lookup has been completed)
Many thanks!