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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.0.4, 5.1.0-rc0, 4.4.11
    • Component/s: None
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v5.0, v4.4

      Description

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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: