MongoDB DEV · Question 203 · Multiple choice

Indexes and Performance: Question 2 Consider a collection called routes with the following index: { "dst_airport": 1, "src_airport": 1, "airline.iata": 1 } Which of the following queries are able to use the index? Check all that apply:

Answer options

  1. A.
    db.routes.find({"src_airport":"JFK", "airline.iata":"EIN"})
  2. B.
    db.routes.find({"dst_airport":"JFK", "airline.iata":"EIN"})
  3. C.
    db.routes.find({"airline.iata":"EIN"})
  4. D.
    db.routes.find({"src_airport":"JFK"})
  5. E.
    db.routes.find({"dst_airport":"JFK"})

Answer confidence: High

Correct answer: B, E

Explanation language: Chinese

复合索引 { dst_airport: 1, src_airport: 1, airline.iata: 1 } 只能按最左前缀使用,查询里必须包含 dst_airport:B(dst_airport + airline.iata,前缀等值 + 后续字段过滤)和 E(仅 dst_airport)可用。A 只给了第二列 src_airport 与 airline.iata、C 只给 airline.iata、D 只给 src_airport,都缺最左前缀,无法形成有效的索引边界。

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 ↗