Where does the merging of aggr results takes place

Blockquote

In the videos its being mentioned that merging of aggregation pipeline results takes place in mongos when ranged query being fired against shards.

But it documentation its mentioned that merging of aggregation pipeline results takes place in random shard.

Where exactly merging of results takes place.

Could you please share a link to this documentation?

I had a similar question last year, so you’ll find this thread useful.

The documentations are:
https://docs.mongodb.com/manual/core/sharded-cluster-query-router/#routing-and-results-process
https://docs.mongodb.com/manual/core/aggregation-pipeline-sharded-collections/

Basically, the documentation is more accurate for the current version of MongoDB.

1 Like

Hi @sudhakar_41579,

Can you please share the name of the video lecture ?

I guess for any non-blocking aggregation stage the merging can take place on mongos. With the blocking stages such as sort, it takes place on any random shard to avoid overloading of the Primary shard. Then again, there are few aggregation stage which may require this merging to take place on the primary shard.

Documentation are more accurate than the videos because they are regularly updated. So, please refer the documentation page shared by @007_jb in the previous post.

~ Shubham