Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions source/core/aggregation-pipeline-sharded-collections.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,16 @@ to be done on the primary shard.
.. versionchanged:: 3.6

When aggregation operations run on multiple shards, the results are
routed to the :binary:`~bin.mongos` to be merged. However, :pipeline:`$out`
and :pipeline:`$lookup` must run on the :ref:`primary shard <primary-shard>`
and are aggregated there.
routed to the :binary:`~bin.mongos` to be merged, except in the
following cases:

- If the pipeline includes the :pipeline:`$out` or
:pipeline:`$lookup` stages, the merge runs on the
:ref:`primary shard <primary-shard>`.

- If the pipeline includes a sorting or grouping stage, and the
:ref:`allowDiskUse <aggregate-cmd-allowDiskUse>` setting is enabled,
the merge runs on a randomly-selected shard.

Optimization
------------
Expand Down
4 changes: 3 additions & 1 deletion source/reference/command/aggregate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ arguments:



* - ``allowDiskUse``
* - .. _aggregate-cmd-allowDiskUse:

``allowDiskUse``

- boolean

Expand Down