Skip to main content

Why do sharded clusters struggle with scatter-gather queries?

Senior MongoDB
Quick Answer Scatter-gather queries hit every shard because the query doesn't include the shard key. mongos fans out to all shards, each returns results, mongos merges them. For sorting, all shards sort and return top N results, mongos re-sorts and picks top N. This is expensive and gets worse as shard count grows. Fix: include the shard key in queries to target a single shard (targeted query).

Answer

Scatter-gather queries hit all shards, increasing latency and limiting scalability. Good shard keys minimize this pattern.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice