Currently the planner only considers an OR plan eligible for explodeForSort() if its children are all IXSCANs. In theory a FETCH shouldn’t prevent a SORT_MERGE plan from being eligible.
The attached explain from 3.2.4 seems to demonstrate the problem. Rather than leveraging the index to create a SORT_MERGE plan, a SORT plan is generated as a result of the FETCH required to satisfy the {$exists:false} filter.
- is related to
-
SERVER-96421 Support explode for sort optimization when there is a FETCH after OR
- Backlog