|
When only retrieving fields from a covered index, if the fields to be returned are specified with true instead of 1, explain() indicates that the covered index isn't used.
PRIMARY> db.version();
|
2.0.1
|
PRIMARY> db.temp.getIndexes();
|
[
|
{
|
"v" : 1,
|
"key" : {
|
"_id" : 1
|
},
|
"ns" : "test.temp",
|
"name" : "_id_"
|
}
|
]
|
PRIMARY> db.temp.find({_id:'1'},{_id:true}).explain();
|
{
|
"cursor" : "BtreeCursor _id_",
|
"nscanned" : 0,
|
"nscannedObjects" : 0,
|
"n" : 0,
|
"millis" : 13,
|
"nYields" : 0,
|
"nChunkSkips" : 0,
|
"isMultiKey" : false,
|
"indexOnly" : false,
|
"indexBounds" : {
|
"_id" : [
|
[
|
"1",
|
"1"
|
]
|
]
|
}
|
}
|
PRIMARY> db.temp.find({_id:'1'},{_id:1}).explain();
|
{
|
"cursor" : "BtreeCursor _id_",
|
"nscanned" : 0,
|
"nscannedObjects" : 0,
|
"n" : 0,
|
"millis" : 0,
|
"nYields" : 0,
|
"nChunkSkips" : 0,
|
"isMultiKey" : false,
|
"indexOnly" : true,
|
"indexBounds" : {
|
"_id" : [
|
[
|
"1",
|
"1"
|
]
|
]
|
}
|
}
|
If explain is truly correct here, this seems to violate the principle of least astonishment.
|