|
It is confusing that explain() does not indicate whether an index filter was applied. Including this information can significantly help the slow-query debugging process.
> db.foo.insert({_id:0, a:1})
|
SingleWriteResult({
|
"writeErrors" : [ ],
|
"writeConcernErrors" : [ ],
|
"nInserted" : 1,
|
"nUpserted" : 0,
|
"nUpdated" : 0,
|
"nModified" : 0,
|
"nRemoved" : 0,
|
"upserted" : [ ]
|
})
|
> db.foo.runCommand("planCacheSetFilter",{query:{a:1},indexes:[{_id:1}]})
|
{ "ok" : 1 }
|
> db.foo.find({a:1}).hint({a:1}).explain()
|
{
|
"cursor" : "BasicCursor", // no indication as to why hinted index is not being used
|
"n" : 1,
|
"nscannedObjects" : 1,
|
"nscanned" : 1,
|
"nscannedObjectsAllPlans" : 1,
|
"nscannedAllPlans" : 1,
|
"scanAndOrder" : false,
|
"indexOnly" : false,
|
"nYields" : 0,
|
"nChunkSkips" : 0,
|
"millis" : 0,
|
"server" : "Rassi-MacBook-Pro.local:27017"
|
}
|
>
|
|