-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.8.0-rc1
-
Component/s: Querying
-
None
-
Query Execution
Currently, when scanning any index for a number of given ranges (unique or not) we check after each found value to confirm if there is a match or we should advance the range.
If we are using a unique index (or a field which can be confirmed to be unique by the presence of another unique index) we don't need to perform this extra check, as there can only be one matching value.
Simple reproducer
for(i=0;i<101;i++){db.t2.insert({x:i})} db.t2.ensureIndex({x:1}, {unique:true}) db.t2.find({x:{$in:[3,50,74,100]}}).explain(true)
.... "keysExamined" : 7,
- related to
-
SERVER-16891 Special handling of "idhack" queries should be moved to query planner
- Backlog