-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
Query Optimization
If the $group stage spills to disk, then the results will be output in order of their _id. If this is the case, we could potentially take advantage of this knowledge, by removing a subsequent sort on _id, or by making a subsequent group convert to streaming.
We should add some sort of prep stage to pipeline execution, so that we will know if the $group is going to spill to disk before we have to make decisions on whether outputs are sorted.