MongoDB DBA · 题目 370 · 多选

Consider the following index in the buildings collection: { height: 1 } Which of the following queries could use this index? Check all that apply:

题目选项

  1. A.
    db.buildings.find({ year: { $lte: 1980 } })
  2. B.
    db.buildings.find({ height: { $gt: 50 } })
  3. C.
    db.buildings.find({ height: 100, city: "London" })

答案置信度:高

正确答案:B、C

解析语言:中文

单字段索引 {height:1} 只能服务带 height 条件的查询:A 是 height 的范围查询,C 是 height 等值过滤后再用 city 做残余过滤,两种都能先用索引缩小候选文档。B 只查 year,索引中根本没有该字段,只能全集合扫描。C 里 city 没有索引并不妨碍使用 height 索引,只是过滤要回表后再判断。

所在套题

此题在题库中有 2 条记录。公开详情合并相同题干和选项;完整公开题展示置信度最高的一条记录,其他题目仅展示摘要。按套学习保留每条记录原有的答案、解析和置信度。

作者 · 作品 · 开源

作者与 MongoDB 作品

专注数据平台、MongoDB 迁移同步与云运维产品研发。

有任何 MongoDB 需求,均可联系作者。

联系作者 ↗mlhp123@outlook.com

支持作者

如果题库对您有帮助,欢迎自愿扫码打赏。

支付宝扫码打赏作者打开打赏原图 ↗