-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.4.8, 2.6.3
-
Component/s: Index Maintenance, Querying
-
None
-
ALL
given the following collection:
db.test.find().pretty() { "_id" : ObjectId("53fe2798a3cfa2769eb8ca96"), "name" : "jon", "a" : [ { "someDate" : ISODate("2011-02-28T12:49:00Z") }, { "someDate" : ISODate("2011-03-31T11:56:00Z") }, { "someDate" : ISODate("2012-12-03T20:22:00Z") } ] }
and the following indexes:
db.test.getIndexes() [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "db.test", "name" : "_id_" }, { "v" : 1, "key" : { "a.someDate" : 1 }, "ns" : "db.test", "name" : "a.someDate_1" } ]
here is the explain of the query:
db.test.find({'a' :{$elemMatch : {'someDate':{$gte:ISODate("2011-03-01T00:00:00"), $lte:ISODate("2011-05-01T00:00:00")}}}}).explain() { "cursor" : "BtreeCursor a.someDate_1", "isMultiKey" : true, "n" : 1, "nscannedObjects" : 2, "nscanned" : 2, "nscannedObjectsAllPlans" : 2, "nscannedAllPlans" : 2, "scanAndOrder" : false, "indexOnly" : false, "nYields" : 0, "nChunkSkips" : 0, "millis" : 0, "indexBounds" : { "a.someDate" : [ [ ISODate("2011-03-01T00:00:00Z"), ISODate("0NaN-NaN-NaNTNaN:NaN:NaNZ") ] ] }, "server" : "local":27017" }
1. the collection is being scanned twice
2. upper index bound is NaN
I would expect the index to be used for this range query with proper lower/upper bounds.
- duplicates
-
SERVER-15086 Allow for efficient range queries over non-array fields in multikey indices
- Closed
- related to
-
SERVER-6720 Range query with compound multikey index scans more objects than needed
- Closed
-
SERVER-14618 Wrong index bounds when using "hint"
- Closed