MongoDB DBA · Question 237 · Single choice

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:

Answer options

  1. A.
    db.coll.find({ "a": 18 , "b": 13 } , { "_id": 0 , "a": 1 , "b": 1 })
  2. B.
    db.coll.find({ "a": 18 })
  3. C.
    db.coll.find({ })
  4. D.
    db.coll.find({ "c": 25 , "d": 13 } , { "_id": 0 , "d": 1 })
  5. E.
    db.coll.find({ "c": 25 , "d": 13 } , { "a": 1 })

Answer confidence: High

Correct answer: D

Explanation language: Chinese

覆盖查询要求过滤字段与返回字段都在同一个索引内且排除 _id。D 用 {c:1,d:1} 过滤 c、d 并只返回 d、排除 _id,完全被索引覆盖。A 用两个单字段索引(a 与 b 不在同一个索引里)无法构成覆盖查询;B、C 没有投影、要返回整条文档;E 返回的 a 不在 {c:1,d:1} 索引中,都必须回表。

Papers containing this question

This question appears in 3 bank records. Public pages combine identical prompts and options. Selected questions display the highest-confidence record; the others show a short preview. Paper-based learning preserves each record's answer, explanation, and confidence.

AUTHOR · PROJECTS · OPEN SOURCE

Author & MongoDB projects

Building data platforms, MongoDB migration and sync tools, and cloud operations products.

Contact the author for any MongoDB needs.

Contact the author ↗mlhp123@outlook.com

Support the author

If this question bank helps you, optional donations are welcome.

Scan with Alipay to support the authorOpen full-size donation image ↗