Conditionally order $match with $unwind

XMLWordPrintableJSON

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

      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 (Inactive)
              Reporter:
              Jeffrey Yemin
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: