-
Type: Task
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Labels:
Hello team,
I was using $lookup in an aggregation query, but using
{ explain: true }at the end of the aggregate() method, I was having trouble getting index stats for the foreign collection i.e. the collection in the "from" part of the $lookup. The index stats for the local collection were still available using
{ explain: true }.
However, when I ran it like explain("allPlansExecution").aggregate(...), the explain() output had index usage stats for the foreign collection as well.
For reference, you can't run a query like .aggregate(...).explain() in the Mongo shell, so you need to put explain() before aggregate() like explain(...).aggregate(...).
I had some trouble figuring out how to find the index stats for $lookup because of the difference in results between
{ explain: true }and .explain(), so I would really appreciate if this was documented somewhere. I think the customers would appreciate it too.
Thanks,
Matt