-
Type: Question
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.0.4
-
Component/s: Index Maintenance, Querying
-
None
1. Create two documents in collection "test"
{ "time": [ { "hour": 17 }, { "hour": 18 }, { "day": 0 } ] }, { "time": [ { "hour": 17 }, { "hour": 19 }, { "day": 1 } ] }
2. Build an index:
db.test.ensureIndex({ "time.hour" : 1, "time.day" : 1 }, { "name" : "time.hour_1_time.day_1", "background" : true, })
3. Now run a query:
db.test.find({ 'time.hour': 17, 'time.day': 1, }).explain(true)
4. See that winningPlan includes a filter on 'time.day' field and index bounds do not use a value from the query
"winningPlan" : { "stage" : "FETCH", "filter" : { "time.day" : { "$eq" : NumberInt(1) } }, "inputStage" : { "stage" : "IXSCAN", "keyPattern" : { "time.hour" : NumberInt(1), "time.day" : NumberInt(1) }, "indexName" : "time.hour_1_time.day_1", "isMultiKey" : true, "direction" : "forward", "indexBounds" : { "time.hour" : [ "[17.0, 17.0]" ], "time.day" : [ "[MinKey, MaxKey]" ] } } }
The question is: why query is not fully covered by the index.