- 
    Type:
Improvement
 - 
    Resolution: Unresolved
 - 
    Priority:
Major - P3
 - 
    None
 - 
    Affects Version/s: 8.0.0
 - 
    Component/s: None
 
- 
        Query Optimization
 - 
        None
 
- 
        None
 - 
        None
 - 
        None
 - 
        None
 - 
        None
 - 
        None
 
Based on SERVER-84347 which was supposed to make DISTINCT_SCAN optimization available to $top and $bottom accumulators, it seems to rely on this form of group:
{$group: {
    _id: "$a", 
    accum: {$top: {
          output: "$b", 
          sortBy: {a: 1, b: 1}}}
}}
But no one would know to write that - took me a few minutes to figure it out:
{$group: {
    _id: "$a", 
    accum: {$top: {
          output: "$b", 
          sortBy: {b: 1}}}
}}
is the normal and expected syntax that we should expect to optimize. Of course it would rely on index on {a: 1, b: 1} which is its own little side issue ...
- is related to
 - 
                    
SERVER-84347 Use DISTINCT_SCAN with $top/$bottom accumulators
-         
 - Closed
 
 -