Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-15242

[Server] Using { explain: true } with .aggregate() does not give as much information as .explain("allPlansExecution")

      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

            Assignee:
            david.hou@mongodb.com David Hou
            Reporter:
            matt.javaly@mongodb.com Matthew Javaly
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              15 weeks, 4 days ago