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

Conditionally order $match with $unwind

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

      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}} }
      ]
      

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

              Created:
              Updated:
              Resolved: