Strange behaviour for MongoDB covered query -
if have following collection
{ "_id" : "a" } { "_id" : "b" } { "_id" : "c" }
normal query
if run following query
db.test.find({_id: "a"}, {_id: 1}).explain("executionstats")
it returns
"executionstats" : { "totalkeysexamined" : 1, "totaldocsexamined" : 1 }
query hint
now strange part. if run following query
db.test.find({_id: "a"}, {_id: 1}).hint({_id: 1}).explain("executionstats")
it returns
"executionstats" : { "totalkeysexamined" : 1, "totaldocsexamined" : 0 }
question
why normal query examining document, if want _id?
server version: v3.2.1
what doing using _id index instead of going through collection. see indexes using
collection.getindexes()
in sense mongo server (query optimizer) used index specified (_id) , did not have go through collection
hop helps
Comments
Post a Comment