- 
    Type:Improvement 
- 
    Resolution: Unresolved
- 
    Priority:Major - P3 
- 
    None
- 
    Affects Version/s: None
- 
    Component/s: Aggregation Framework
- 
        Query Optimization
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
As part of SERVER-4507, a virtual method was introduced on DocumentSource, getOutputSorts, that allows the following stage to determine what, if any, sorting is present on the stream of input documents. At the moment, only $group takes advantage of this knowledge. Where possible, other stages should be expanded to take advantage of it as well. Of course, the primary example is $sort, which can do far less work if the input is already sorted by the sort key, but other possibilities may exist as well.