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

$unionWith explain with mode "executionStats" does not account for stages which are pushed down

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.4.11, 5.0.4, 5.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • ALL
    • v5.0, v4.4

      This is very similar to SERVER-50246, however in that case there was no document source rewrite taking place per se but simply executing the sub-pipeline as part of explain was losing stages in the sub-pipeline that were eligible to push into the find layer. For instance, SERVER-50246 would fix an issue like this:

      [{$unionWith: {coll: "test", pipeline: [{$match: {_id: 1}}]}}]
      

      However, there was an oversight with the implementation whereby the inner $match can actually come from a rewrite for a pipeline like this:

      [{$unionWith: "test"}, {$match: {_id: 1}}]
      

      which gets optimized to:

      [{$match: {_id: 1}}, {$unionWith: {coll: "test", pipeline: [{$match: {_id: 1}}]}}]
      

      The current explain output for the second example does not include the $match pushdown, and subsequently may not show the correct access plan (e.g. IXSCAN on _id).

            Assignee:
            nicholas.zolnierz@mongodb.com Nicholas Zolnierz
            Reporter:
            nicholas.zolnierz@mongodb.com Nicholas Zolnierz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: