[SERVER-28980] aggregation can subsume $sort into $group when $first/$last are present Created: 26/Apr/17 Updated: 06/Dec/22 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Asya Kamsky | Assignee: | Backlog - Query Optimization |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | asya, optimization, performance | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Assigned Teams: |
Query Optimization
|
||||||||||||
| Participants: | |||||||||||||
| Case: | (copied to CRM) | ||||||||||||
| Description |
|
When the following is the pattern of pipeline:
We can subsume the sort into group and get rid of the stage otherwise - have the logic of first/last by certain order in the $group itself. This would allow merging on the $group (SERVER-28942) rather than $sort - in fact, for all sorts, since sort does not impact later (post-group) stages. This optimization may not need to happen if sort can be subsumed into query pushdown (when index is available) or when another index optimization is being used (i.e. |
| Comments |
| Comment by Asya Kamsky [ 21/Sep/22 ] |
|
I think with addition of $topN operators this ticket may not be relevant anymore (unless we take it to mean "automatically execute sort+group with $first as $topN?) |