Skip to content

Commit 1bea077

Browse files
committed
DOCS-13229 correct merge behavior sharded cluster
1 parent 95213fa commit 1bea077

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

source/core/aggregation-pipeline-sharded-collections.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,16 @@ to be done on the primary shard.
3030
.. versionchanged:: 3.6
3131

3232
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.
3643

3744
Optimization
3845
------------

0 commit comments

Comments
 (0)