59. Consider the following query: db.movies.aggregate([ { $lookup: { from: "cinemas", localField: "theater", foreignField: "movie", as: "theater_shows" } } ]) If this query is run against a sharded collection, where will the $lookup aggregation stage take place? Choose the best answer:
题目选项
- A.A random shard
- B.The primary shard
- C.The mongos
- D.The shard containing the most movies documents
- E.Each individual shards
答案置信度:高
正确答案:B
解析语言:中文
含 $lookup 的聚合不能把归并放在 mongos:官方规定 $lookup、$out 这类阶段的合并部分在集合的 primary shard 上执行,因此该 $lookup 在 primary shard 上完成(B)。C 是本题最有迷惑性的选项——不含 $lookup/$out 的普通管道归并才发生在 mongos,所以 D、E、A 均不成立。