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

Conditionally order $match with $unwind

    XMLWordPrintable

Details

    • Fully Compatible
    • Query 10 (02/22/16), Query 11 (03/14/16), Query 12 (04/04/16)

    Description

      The subset of a $match following an $unwind that does not filter on the unwound field can be moved up in the pipeline.

      For example:

      [
        {'$unwind' : "$x"}, 
        {'$match' : {_id : 1, x : {'$gt': 3}  } }
      ]
      

      is equivalent to:

      [ 
         {'$match' : {_id : 1} }, 
         {'$unwind' : "$x"}, 
         {'$match' : {x : {'$gt': 3}} }
      ]
      

      Attachments

        Issue Links

          Activity

            People

              benjamin.murphy Benjamin Murphy
              jeff.yemin@mongodb.com Jeffrey Yemin
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: