15. Consider a collection called coll where you have built indexes with the following commands: db.coll.createIndex({ "a": 1 }) db.coll.createIndex({ "b": 1 }) db.coll.createIndex({ "c": 1 , "d": 1 }) Which of the following queries is a fully covered query? Choose the best answer:
题目选项
- A.db.coll.find({ "a": 18 , "b": 13 } , { "_id": 0 , "a": 1 , "b": 1 })
- B.db.coll.find({ "a": 18 })
- C.db.coll.find({ })
- D.db.coll.find({ "c": 25 , "d": 13 } , { "_id": 0 , "d": 1 })
- E.db.coll.find({ "c": 25 , "d": 13 } , { "a": 1 })
答案置信度:高
正确答案:D
解析语言:中文
覆盖查询要求过滤字段与返回字段都在同一个索引内且排除 _id。D 用 {c:1,d:1} 过滤 c、d 并只返回 d、排除 _id,完全被索引覆盖。A 用两个单字段索引(a 与 b 不在同一个索引里)无法构成覆盖查询;B、C 没有投影、要返回整条文档;E 返回的 a 不在 {c:1,d:1} 索引中,都必须回表。