[SERVER-9370] Optimize $match $unwind $match sequence in pipeline Created: 17/Apr/13 Updated: 16/Mar/23 Resolved: 20/May/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Asya Kamsky | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | optimization | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
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: 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. |
| Comments |
| Comment by clemilson barcelos [ 06/May/18 ] |
|
Good evening! |
| Comment by Asya Kamsky [ 08/Apr/15 ] |
|
This is related to request to have $elemMatch or $filter in support of $map so it may become redundant in light of other possible optimizations. |