|
Fixed by the rewrite of the query planner for 2.6. The new query system considers solving {$exists: true} queries by scanning sparse indices:
> db.version()
|
2.6.7
|
> t = db.t
|
test.t
|
> t.drop()
|
true
|
> t.ensureIndex({a: 1}, {sparse: true})
|
{
|
"createdCollectionAutomatically" : true,
|
"numIndexesBefore" : 1,
|
"numIndexesAfter" : 2,
|
"ok" : 1
|
}
|
> t.ensureIndex({b: 1})
|
{
|
"createdCollectionAutomatically" : false,
|
"numIndexesBefore" : 2,
|
"numIndexesAfter" : 3,
|
"ok" : 1
|
}
|
> t.insert({a: 1})
|
WriteResult({ "nInserted" : 1 })
|
> t.insert({b: 1})
|
WriteResult({ "nInserted" : 1 })
|
> t.find({a: {$exists: true}}).explain()
|
{
|
"cursor" : "BtreeCursor a_1",
|
"isMultiKey" : false,
|
"n" : 1,
|
"nscannedObjects" : 1,
|
"nscanned" : 1,
|
"nscannedObjectsAllPlans" : 1,
|
"nscannedAllPlans" : 1,
|
"scanAndOrder" : false,
|
"indexOnly" : false,
|
"nYields" : 0,
|
"nChunkSkips" : 0,
|
"millis" : 0,
|
"indexBounds" : {
|
"a" : [
|
[
|
{
|
"$minElement" : 1
|
},
|
{
|
"$maxElement" : 1
|
}
|
]
|
]
|
},
|
"server" : "dstorch-desktop:27017",
|
"filterSet" : false
|
}
|
Resolving as a duplicate of SERVER-10026.
|