MongoDB DBA · 题目 60 · 多选

60. Consider the following read commands that are sent to your sharded cluster: Query A db.users.find({"userId": <String>}) Query B db.users.find({"last_login": <ISODate>, "userId": <String>}) Query C db.users.aggregate([ {"$match": {"last_login": <ISODate>, "isActive": true}}, {"$group": { "_id": "$userId", "count": {"$sum": 1} } } ]) The collection users has been sharded with the following command: sh.shardCollection( "app.users", { "userId": 1, "last_login": 1, "isActive": 1 } ) Given the chosen shard key, which queries will be routed in the sharded cluster? Check all that apply:

题目选项

  1. A.
    A
  2. B.
    B
  3. C.
    C

答案置信度:高

正确答案:A、B

解析语言:中文

定向路由要求查询包含分片键的前缀字段:查询 A 只有 userId(前缀)可以定向;查询 B 虽然字段顺序不同,但 userId 与 last_login 都是等值条件,两个前缀字段齐全,仍可算出目标 chunk 范围。查询 C 只过滤 last_login、isActive,缺少前缀 userId,无法定位 chunk,只能广播。

所在套题

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

作者 · 作品 · 开源

作者与 MongoDB 作品

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

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

联系作者 ↗mlhp123@outlook.com

支持作者

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

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