56. Consider a collection called sample which is sharded using the following shard key: { "a": 1 , "b": 1 } Which of the following queries will enable a mongos to target queries at specific shards rather than doing a scatter gather query? Check all that apply:
题目选项
- A.db.sample.find( { "b": { "$gt": 5 } )
- B.db.sample.find( { "a": { "$lte": 7 } } )
- C.db.sample.find( { "a": 12, "b": { "$gt": "jello" } } )
答案置信度:高
正确答案:B、C
解析语言:中文
分片键是 {a:1,b:1},只有包含前缀 a 的查询才能被 mongos 定向裁剪到部分分片:B 是对前缀 a 的范围查询、C 是 a 等值加 b 范围,二者都能定向(B 可能命中多个分片,但不是全集群广播)。A 只查 b、缺少前缀 a,只能 scatter-gather 广播到所有分片。