Details
-
Improvement
-
Resolution: Unresolved
-
Major - P3
-
None
-
2.6.3
-
None
-
Query Optimization
Description
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.