Skip to main content
InterviewHubPRO
Section Overview
Q23

Question 23 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

46%
MongoDB & NoSQL (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

What are Targeted Queries vs Scatter-Gather Queries in Sharded Clusters?

senior LevelmongodbAdvanced Internals

In Simple Words:

  • Targeted Query: The query includes the Shard Key in the find() criteria. mongos routes the query directly to the single exact shard holding that data. High performance, sub-5ms latency.
  • Scatter-Gather Query: The query does NOT include the shard key. mongos must broadcast the query to every single shard in the cluster, wait for all to respond, sort, and merge. Severely degrades cluster throughput at scale.