Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
2.5.5
-
None
-
None
-
Major Change
-
ALL
Description
The way indexed queries against sparse index work changed from 2.4.x to 2.5.5 - in pre-2.5 the results of $eq and $ne of same value would add up to the number of entries in the index, in 2.5.5+ it's the total number of documents (same as with non-sparse index).
Not that this only impacts $ne - $gt shows the same behavior as before.
db.test.insert({a:1})
|
db.test.insert({a:1,b:1})
|
db.test.insert({b:1})
|
db.test.ensureIndex({a:1},{sparse:true})
|
Results in 2..5.5
> db.test.find().count()
|
3
|
> db.test.find({a:1}).count()
|
2
|
> db.test.find({a:{$ne:1}}).count()
|
1
|
> db.test.find({a:{$gt:1}}).count()
|
0
|
And in 2.4.8
> db.test.find().count()
|
3
|
> db.test.find({a:1}).count()
|
2
|
> db.test.find({a:{$ne:1}}).count()
|
0
|
> db.test.find({a:{$gt:1}}).count()
|
0
|
Attachments
Issue Links
- is duplicated by
-
SERVER-13939 Unexpected behavior of query planner with sparse indices
-
- Closed
-
- is related to
-
SERVER-12532 Negate index bounds for $not instead of defaulting to a collection scan
-
- Closed
-
- related to
-
SERVER-13986 Creating a sparse index makes the not equals query to return diferent results.
-
- Closed
-