[SERVER-19153] Conditionally push $match before $project Created: 26/Jun/15 Updated: 15/May/18 Resolved: 06/Oct/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework, Performance |
| Affects Version/s: | None |
| Fix Version/s: | 3.4.0-rc1 |
| Type: | New Feature | Priority: | Critical - P2 |
| Reporter: | Craig Wilson | Assignee: | David Storch |
| Resolution: | Done | Votes: | 1 |
| Labels: | bi-performance, optimization | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||||||||||||||||||
| Sprint: | Query 2016-09-19, Query 2016-10-10 | ||||||||||||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||||||||||||
| Description |
|
I was looking at the optimizing aggregation pipelines docs page and didn't see this one listed. This is only possible if the subsequent $match doesn't use any computed fields, but there could be a large win with regards to index usage if you could move the $match prior to a $project. For example:
is the same as
because the $match is only using fields that exist in the original document. |
| Comments |
| Comment by Githook User [ 06/Oct/16 ] |
|
Author: {u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}Message: |
| Comment by David Storch [ 03/Oct/16 ] |
|
I've limited the scope of this ticket to be specifically about swapping $match with $project. Swapping $sort and $project is now a separate work item tracked by SERVER-26442. |
| Comment by Charlie Swanson [ 26/Jul/16 ] |
|
Bumping to 3.3 Required to make views more usable. |
| Comment by Charlie Swanson [ 21/Jan/16 ] |
|
Yep, this looks like a duplicate. Closing as such. |
| Comment by Asya Kamsky [ 20/Jan/16 ] |
|
Part of |