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

Optimize $match $unwind $match sequence in pipeline

      When looking to do aggregations on a subset of documents in arrays, the current "best" practice is to do $match first, then $unwind then $match again.

      In other words, if our pipeline is:
      {$match:{array.Member:"value"}},{$unwind:"$array"},{$match:{"array.Member":"value"}}

      if we can optimize this into something that eliminates unneeded array elements along with unneeded fields this could be reduced to one $match and no $unwind.

      redbeard0531 this is what we talked about yesterday, please re-write the description if I didn't capture what we were discussing accurately.

            Assignee:
            Unassigned Unassigned
            Reporter:
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: