Chapter 5: performance considerations in distributed systems part 2

Looking for clarification on sort merge operation. The video talks about “local sort merge” happening and a final sort merge happening on the primary shard. What if the target shards for the query doesn’t involve “primary shard”, would the final “sort merge” happen on the primary shard?

A summary of this is in this post. I’d recommend reading the entire thread also.

Thanks. So lesson video is misleading as the document clearly mentions that the primary shard is involved only 2 cases, when either data is fetched from primary shard as part of the query or if a unsharded collection in the same db as a sharded collection is looked up as part of aggregation. Also primary shard may get involved if the overflow to disk happens to pick primary shard for sorts on disk.

Hi @gdinakar,

We can use any of the shards (or mongos) to do final sort, limit and skip steps.
Please refer to the following piece of documentation as well:

We are in process of upgrading our course content. So, please feel free to reach out in discussion forums if you have any confusion about the concepts.

Thanks,
Sonali