File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -30,9 +30,16 @@ to be done on the primary shard.
30
30
.. versionchanged:: 3.6
31
31
32
32
When aggregation operations run on multiple shards, the results are
33
- routed to the :binary:`~bin.mongos` to be merged. However, :pipeline:`$out`
34
- and :pipeline:`$lookup` must run on the :ref:`primary shard <primary-shard>`
35
- and are aggregated there.
33
+ routed to the :binary:`~bin.mongos` to be merged, except in the
34
+ following cases:
35
+
36
+ - If the pipeline includes the :pipeline:`$out` or
37
+ :pipeline:`$lookup` stages, the merge runs on the
38
+ :ref:`primary shard <primary-shard>`.
39
+
40
+ - If the pipeline includes a sorting or grouping stage, and the
41
+ :ref:`allowDiskUse <cmd-aggregate-allowDiskUse>` setting is enabled,
42
+ the merge runs on a randomly-selected shard.
36
43
37
44
Optimization
38
45
------------
You can’t perform that action at this time.
0 commit comments