Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardMongoDBcovered queries internalsSingle-choice MCQ

For a query to be covered, the projection must exclude _id unless _id is part of the index. Why does keeping the default _id projection break coverage on an index like {a:1, b:1}?

db.c.createIndex({ a: 1, b: 1 }) db.c.find({ a: 5 }, { a: 1, b: 1 }) // not covered (_id returned) db.c.find({ a: 5 }, { a: 1, b: 1, _id: 0 }) // covered