-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
Query Optimization
-
Query 2020-04-06, Query 2020-04-20, Query 2020-05-04, Query 2020-05-18
Currently, we only replace an OR_STAGE with a MERGE_SORT_STAGE when the sort order of the underlying indexes are shared and match the desired sort order of the query.
The OR_STAGE uses unbounded memory to de-duplicate records. The MERGE_SORT_STAGE currently seems to do the same, but could be optimized to use far less memory than the OR_STAGE since duplicate records are coming in from child stages in the same order.
Given that MERGE_SORT_STAGE can be optimized to avoid unbounded memory, we should consider aggressively using it instead of OR_STAGEs, and re-SORTing afterwards (which happens in the OR_STAGE case as well).
- is duplicated by
-
SERVER-27658 $or should choose SORT_MERGE instead of OR if all children provide the same sort
- Closed
- related to
-
SERVER-41142 Compound index on an array field is not being used correctly
- Closed