[SERVER-31072] reorder $limit before $lookup in pipeline Created: 13/Sep/17 Updated: 30/Oct/23 Resolved: 17/Dec/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | 4.3.3 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Asya Kamsky | Assignee: | Katherine Wu (Inactive) |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | QFB, asya, neweng, optimization, performance, qopt-team, storch | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||
| Sprint: | Query 2019-12-16, Query 2019-12-30 | ||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
In pipeline:
moving $limit before the first $lookup stage will significantly reduce the amount of work that lookup and addFields have to do. We currently don't reorder $limit with $lookup, it appears. |
| Comments |
| Comment by Githook User [ 17/Dec/19 ] |
|
Author: {'name': 'Katherine Wu', 'email': 'katherine.wu@mongodb.com', 'username': 'kaywux'}Message: |
| Comment by David Storch [ 09/Oct/19 ] |
|
This came up in |
| Comment by David Storch [ 06/Oct/17 ] |
|
This is probably better solved by eliminating batching behavior in DocumentSourceCursor. This is tracked by SERVER-27829, but is complex due to the changes required in locking behavior. |
| Comment by Asya Kamsky [ 27/Sep/17 ] |
|
I see there's a comment about that here: So maybe the sort reorder before $lookup should be handled there. |
| Comment by Asya Kamsky [ 27/Sep/17 ] |
|
Not sure if this ticket should also cover moving $sort (on top document field) before $lookup or if that should be a separate ticket (since limit sometimes gets absorbed into $sort I think they are related). |
| Comment by Asya Kamsky [ 13/Sep/17 ] |
|
Obviously this optimization can only be safely applied to a $lookup without an $unwind. |