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

Explain against a pipeline containing $unionWith does not accurately count executionStats from sub-pipeline

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: None
    • Labels:
    • Operating System:
      ALL

      Description

      When explaining a pipeline containing a $unionWith stage, we first exhaust the pipeline to gather the execution stats. For union, this may or may not involve building and targetting its sub-pipeline depending on the subsequent stages (e.g. $limit may allow us to stream results directly from the base collection without using the pipeline). Next, we will serialize the $unionWith stage, at which point we "re-run" the pipeline and gather the explain output for it.

      There are separate issues with this depending on whether we're running in a sharded cluster:

      1. If not sharded: the executionStats reported for the inner pipeline will not take into account subsequent stages such as $limit which could affect the nReturned stat.
      2. If sharded: The initial pass to exhaust the pipeline does not actually pull from the sub-pipeline since the helper we delegate to will see the explain bit and run a scatter-gather to get the results from each shard instead of establishing cursors to iterate. This means that the union stage essentially gets a no-op pipeline back, and the executionStats reported by the union stage itself will not include any potential documents from the sub-pipeline.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-query-optimization Backlog - Query Optimization
              Reporter:
              nicholas.zolnierz Nicholas Zolnierz
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated: