-
Type: Bug
-
Resolution: Duplicate
-
Priority: Critical - P2
-
None
-
Affects Version/s: 3.0.7, 3.2.11, 3.4.0
-
Component/s: Aggregation Framework
-
None
-
ALL
-
When running an aggregation query with a $match and $sort phase against a collection where both the field being queried in the $match step and the $sort step have separate indexes, mongo will always choose to use the index that assists with the $sort, and not the $match. This leads to inefficient collection scan queries!
We came across this bug after upgrading from the 1.X to the 2.X C# mongo driver, but can reproduce it easily in the shell. I have tested this in mongoDB version 3.0 on MMAPv1, as well as 3.2 and 3.4 clusters in Atlas running Wiredtiger, with identical results.
It is easy to reproduce, I have detailed the steps below with a very simple example.
- duplicates
-
SERVER-7568 Aggregation framework favors non-blocking sorts
- Closed