MongoDB DBA · Question 59 · Single choice

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:

Answer options

  1. A.
    A random shard
  2. B.
    The primary shard
  3. C.
    The mongos
  4. D.
    The shard containing the most movies documents
  5. E.
    Each individual shards

Answer confidence: High

Correct answer: B

Explanation language: Chinese

含 $lookup 的聚合不能把归并放在 mongos:官方规定 $lookup、$out 这类阶段的合并部分在集合的 primary shard 上执行,因此该 $lookup 在 primary shard 上完成(B)。C 是本题最有迷惑性的选项——不含 $lookup/$out 的普通管道归并才发生在 mongos,所以 D、E、A 均不成立。

Papers containing this question

This question appears in 3 bank records. Public pages combine identical prompts and options. Selected questions display the highest-confidence record; the others show a short preview. Paper-based learning preserves each record's answer, explanation, and confidence.

AUTHOR · PROJECTS · OPEN SOURCE

Author & MongoDB projects

Building data platforms, MongoDB migration and sync tools, and cloud operations products.

Contact the author for any MongoDB needs.

Contact the author ↗mlhp123@outlook.com

Support the author

If this question bank helps you, optional donations are welcome.

Scan with Alipay to support the authorOpen full-size donation image ↗