[SERVER-26598] conditionally push $match before $addFields in aggregation pipeline Created: 12/Oct/16 Updated: 10/May/18 Resolved: 19/Jan/17 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | 3.5.2 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Asya Kamsky | Assignee: | Kyle Suarez |
| Resolution: | Done | Votes: | 0 |
| Labels: | bkp | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||
| Backport Requested: |
v3.4
|
||||||||||||||||||||||||
| Sprint: | Query 2017-01-23 | ||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||||||||||
| Description |
|
$addFields is a new stage for 3.4 for aggregation and the same optimization that was made for some $project in (i.e. if $match is not on fields that are created/involved in $addFields then it can go before $addFields). |
| Comments |
| Comment by Kyle Suarez [ 19/Jan/17 ] |
|
I'm marking documentation changes as "Needed", in case we want to list this under our Aggregation Pipeline Optimizations page. |
| Comment by Githook User [ 19/Jan/17 ] |
|
Author: {u'username': u'ksuarz', u'name': u'Kyle Suarez', u'email': u'kyle.suarez@mongodb.com'}Message: This allows a $match to be pushed before $addFields if there are no conflicts between the paths |
| Comment by Asya Kamsky [ 13/Oct/16 ] |
|
Moved request to reorder $sort into related SERVER-26442 |
| Comment by Charlie Swanson [ 13/Oct/16 ] |
|
This was thought to be challenging and/or confusing in the initial implementation of The downside to this is it leaves InclusionNode even more muddled, with addPreservedPaths() which should only be called by $project (though is not incorrect to call from elsewhere), and getComputedPaths() which should only be called by $addFields, but is actually incorrect (or at least dangerously misleading) to call in the event that the InclusionNode tree represents both inclusions and computed paths (e.g. within a $project), since it will ignore all included paths. |