-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.4.2
-
Component/s: Querying
-
None
Documents with two fields: {sort:..,x:...}
Index on {sort:1,x:1}
The query on "x" sorted by the sort field doesn't detect proper index bounds for x:
> db.test.find({x:{$gte:1,$lte:3}}).sort({sort:1}).explain("executionStats").executionStats.executionStages.inputStage.indexBounds { "sort" : [ "[MinKey, MaxKey]" ], "x" : [ "[MinKey, MaxKey]" ] }
However, adding an all-inclusive condition on "sort" into the query fixes the problem:
> db.test.find({sort:{$gte:MinKey},x:{$gte:1,$lte:3}}).sort({sort:1}).explain("executionStats").executionStats.executionStages.inputStage.indexBounds { "sort" : [ "[MinKey, MaxKey]" ], "x" : [ "[1.0, 3.0]" ] }
- duplicates
-
SERVER-13197 Tighten index bounds and allow compound index to be chosen when predicate on leading field is not provided
- Backlog