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

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 4.4.11, 5.0.4, 5.1.0-rc0
    • None
    • None
    • Fully Compatible
    • ALL
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: