When we explain a pipeline with mode "executionStats" or above, we first execute the pipeline to completion and then serialize the individual stages. If one of those stages is a $unionWith, then the first phase will target and optimize the sub-pipeline, absorbing any possible stages into the $cursor stage. When serialize() is subsequently called against the $unionWith to generate the 'stages' element of explain, we do the same process again except we've lost any stages which were pushed down into the $cursor/$mergeCursors.
- causes
-
SERVER-50895 $unionWith cached pipeline for explain is leaked if execution does not require sub-pipeline
- Closed
-
SERVER-58888 $unionWith explain with mode "executionStats" does not account for stages which are pushed down
- Closed
- is related to
-
SERVER-49469 explain executionStats for $unionWith incorrectly shows COLLSCAN for inner pipeline
- Closed
- related to
-
SERVER-50597 Explain against a pipeline containing $unionWith does not accurately count executionStats from sub-pipeline
- Backlog
-
SERVER-22622 Improve $lookup explain to indicate query plan on the "from" collection
- Needs Scheduling