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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -