Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-53762

Report aggregate execution stats in explain for the inner side of $lookup

    • Fully Compatible
    • Query Execution 2021-03-08, Query Execution 2021-03-22, Query Execution 2021-04-05

      As part of SERVER-47640, we enhanced the implementation of $lookup to keep track of the PlanSummaryStats associated with the subpipeline. These stats include metrics such as the number of keys examined and the number of documents examined by the subpipeline. Note that the subpipeline may be executed many times, since it is typically executed once per document from the outer (or "local") side. The PlanSummaryStats are tracked in aggregate across all such executions of the subpipeline. So if, for instance, the subpipeline scans a 10 document collection every time it runs, and it runs 5 times, then the result will be a "docsExamined" quantity of 50.

      Now that we are tracking these values, it would be valuable for debugging/diagnostics to expose them in "executionStats" or "allPlansExecution" level explain output. We will need to choose which metrics are exposed, but I think it would at the very least include docs examined and keys examined. This would be especially helpful in understanding the performance properties of the subpipeline, since explain currently does not display the execution plan used on the inner side (see SERVER-22622). Any information in explain as to whether the $lookup subpipeline is cheap or expensive and why would be immensely helpful for query performance debugging scenarios.

            Assignee:
            mohammad.dashti@mongodb.com Mohammad Dashti (Inactive)
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            1 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: