-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
None
-
ALL
-
In my test case below I expect the 3 queries at the end to be index only, but the second one isn't. The third query is like the second but it also references the first column in the index (price) and that query is index only.
db.foo.insert({ price:0, customerid:0}); db.foo.insert({ price:1, customerid:1}); db.foo.insert({ price:2, customerid:2}); db.foo.createIndex({ price:1, customerid:1}); db.foo.find({}, { _id:0, price:1, customerid:1}).sort({price:1, customerid:1}).explain(); db.foo.find({ customerid : { $lt : 0 } }, { _id:0, price:1, customerid:1}).sort({price:1, customerid:1}).explain(); db.foo.find({ price : { $gte : 0 }, customerid : { $lt : 0 } }, { _id:0, price:1, customerid:1}).sort({price:1, customerid:1}).explain(); mdcallag@nuc1:~/b/pmon346$ mdcallag@nuc1:~/b/pmon346$ mdcallag@nuc1:~/b/pmon346$ cat bug.js db.foo.insert({ price:0, customerid:0}); db.foo.insert({ price:1, customerid:1}); db.foo.insert({ price:2, customerid:2}); db.foo.createIndex({ price:1, customerid:1}); db.foo.find({}, { _id:0, price:1, customerid:1}).sort({price:1, customerid:1}).explain(); db.foo.find({ customerid : { $lt : 0 } }, { _id:0, price:1, customerid:1}).sort({price:1, customerid:1}).explain(); db.foo.find({ price : { $gte : 0 }, customerid : { $lt : 0 } }, { _id:0, price:1, customerid:1}).sort({price:1, customerid:1}).explain();
- duplicates
-
SERVER-13197 Tighten index bounds and allow compound index to be chosen when predicate on leading field is not provided
- Backlog