-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: 2.6.3
-
Component/s: Querying
-
None
-
Query Optimization
-
None
-
0
-
None
-
None
-
None
-
None
-
None
-
None
Currently the merge sort implementation returns NEED_TIME every time that it retrieves a key from a child stage. See the code here:
https://github.com/mongodb/mongo/blob/master/src/mongo/db/exec/merge_sort.cpp#L72-L125
As a result, a merge sort plan is disadvantaged in plan ranking, as it could potentially advance more slowly than a plan with, say, a blocking sort stage. As an alternative, the MergeSortStage could retrieve multiple results from its children in one work() before returning NEED_TIME.