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")

    XMLWordPrintable

Details

    • Task
    • Status: Open
    • Minor - P4
    • Resolution: Unresolved
    • None
    • 4.2.0, 4.4, 5.0.0, 5.3.0, 6.0.0
    • manual, Server
    • None
    • ServerDocs2022: Apr26 - May3, ServerDocs2022: Jun1 - Jun14, ServerDocs2022: Jun14 - Jun28, ServerDocs2022: Apr19 - Apr26, ServerDocs2022: May3-May10
    • true

    Description

      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

      Attachments

        Activity

          People

            Unassigned Unassigned
            matt.javaly@mongodb.com Matthew Javaly
            Jess Mokrzecki Jess Mokrzecki
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              17 weeks, 2 days ago