- 
    Type:Improvement 
- 
    Resolution: Unresolved
- 
    Priority:Major - P3 
- 
    None
- 
    Affects Version/s: None
- 
    Component/s: None
- 
    None
- 
        Query Optimization
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
When the distinct scan shard filtering feature is enabled (featureFlagShardFilteringDistinctScan from SPM-3182), $sort + $group pipelines fail to generate the DistinctScan plan. Instead, they opt in for less efficient IndexScan or CollScan plans (when an index is unavailable), even if a DistinctScan plan is available and chosen when the feature is disabled. This results in a significant performance hit.
- is related to
- 
                    SERVER-110803 $top and $bottom ignore sortBy clause when preceeding $sort stage makes it eligible for DISTINCT_SCAN optimization -         
- In Code Review
 
-         
- 
                    SERVER-95198 Take distinct key into account when analyzing sort requirement for distinct -         
- Open
 
-         
- 
                    SERVER-91924 distinct('x', {y:1}) should be able to use DISTINCT_SCAN with an index on {x:1, y:1} -         
- Backlog
 
-