MongoDB DBA · 题目 166 · 单选

50. Your company is planning to deploy 500 million internet connected temperature sensors that will write their data once a day into a new document. These writes account for only 10% of envisioned workload, the other 90% will be read operations analyzing the incoming data. The reads are expected to break down as follows: 60% will read documents for a given device for the last week 20% will read documents for all devices for the last month 15% will read documents where the sensors reported an error in the last day 5% will read documents where temperatures exceeded a certain temperature Here is an example of a document for a device that also reported an error code with its daily data: { "_id:": ObjectId("5c33f89a0a96f53fc48aef25"), "device_id": 184835, "time": ISODate("2019-01-08T01:11:53.681Z"), "temp": 22.5, "counter": 34544, "errors": [ 101 ] } Pick the best shard key out of the following choices: Choose the best answer:

题目选项

  1. A.
    { "counter": 1 }
  2. B.
    { "time": -1, "device_id": 1 }
  3. C.
    { "device_id": 1, "time": 1 }
  4. D.
    { "_id": 1 }
  5. E.
    { "time": 1, "device_id": 1 }

答案置信度:高

正确答案:C

解析语言:中文

{device_id:1, time:1} 把同一设备的数据聚在同一个分片,正好支撑占比最大的“某设备最近一周”范围查询(可定向到单个分片),且 device_id 基数极高不易产生巨型 chunk。B、E 把 time 放在首位会让按时间的查询广播到所有分片并形成写入热点;A 的 counter 与查询模式无关;D 的 _id 无法被业务查询利用。

所在套题

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

作者 · 作品 · 开源

作者与 MongoDB 作品

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

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

联系作者 ↗mlhp123@outlook.com

支持作者

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

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