mongodb - Query without projection is not covered -
see shell example below (assumes db.test not exist):
db.test.ensureindex({info: 1, _id: 1}) db.test.insert({info: "info1"}) db.test.insert({info: "info2"}) db.test.insert({info: "info3"}) db.test.find({info: "info1"}).explain().indexonly //is false db.test.find({info: "info1"}, {_id: 1, info: 1}).explain().indexonly //is true the first explain has indexonly : false whereas second has indexonly : true although 2 queries strictly equivalent.
why isn't db.test.find({info: "info1"}) a covered query?
i have been thinking , testing more , make sense now. if add no projection mongodb has no way of "knowing" if index have fills entire return; mean how can know index covers projection without looking @ documents?
it same select * , select d,e in sql. how can know * same d,e without looking?
if supply projection mongodb can "know" looking @ index give full result set however, without projection cannot.
so after thinking not think bug "quirk".
Comments
Post a Comment