Skip to content

Commit 1455aa5

Browse files
skerschbkay-kim
authored andcommitted
DOCS-7237 adding changes to sharded merge in 3.6
1 parent b127e6f commit 1455aa5

File tree

1 file changed

+34
-9
lines changed

1 file changed

+34
-9
lines changed

source/core/sharded-cluster-query-router.txt

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,43 @@ query modifiers, such as :ref:`sorting<sharding-mongos-sort>`,
4949
are performed on a shard such as the :term:`primary shard` before
5050
:binary:`~bin.mongos` retrieves the results.
5151

52-
.. versionchanged:: 3.2
52+
.. versionchanged:: 3.6
5353

5454
For :doc:`aggregation operations </core/aggregation-pipeline>` that
5555
run on multiple shards, if the operations do not require running on
56-
the database's :term:`primary shard`, these operations can route the results
57-
to any shard to merge the results and avoid overloading the primary
58-
shard for that database.
59-
60-
In some cases, when the :term:`shard key` or a prefix of the shard key is a
61-
part of the query, the :binary:`~bin.mongos` performs a :ref:`targeted
62-
operation<sharding-mongos-targeted>`, routing queries to a subset of
63-
shards in the cluster.
56+
the database's :term:`primary shard`, these operations may route the
57+
results back to the :binary:`~bin.mongos` where the results are then
58+
merged.
59+
60+
There are two cases in which a pipeline is ineligible to run on
61+
:binary:`~bin.mongos`.
62+
63+
The first case occurs when the merge part of the split pipeline
64+
contains a stage which *must* run on a primary shard. For instance,
65+
if ``$lookup`` requires access to an unsharded collection in the same
66+
database as the sharded collection on which the aggregation is running,
67+
the merge is obliged to run on the primary shard.
68+
69+
The second case occurs when the merge part of the split pipeline
70+
contains a stage which may write temporary data to disk, such as
71+
``$group``, and the client has specified ``allowDiskUse:true``. In this
72+
case, assuming that there are no other stages in the merge pipeline
73+
which require the primary shard, the merge will run on a
74+
randomly-selected shard in the set of shards targeted by the
75+
aggregation.
76+
77+
For more information on how the work of aggregation is split among
78+
components of a sharded cluster query, use ``explain:true`` as a
79+
parameter to the :method:`~db.collection.aggregation()` call. The
80+
return will include three json objects. ``mergeType`` shows where the
81+
stage of the merge happens ("primaryShard", "anyShard", or "mongos").
82+
``splitPipeline`` shows which operations in your pipeline have run on
83+
individual shards. ``shards`` shows the work each shard has done.
84+
85+
In some cases, when the :term:`shard key` or a prefix of the shard key
86+
is a part of the query, the :binary:`~bin.mongos` performs a
87+
:ref:`targeted operation<sharding-mongos-targeted>`, routing queries to
88+
a subset of shards in the cluster.
6489

6590
:binary:`~bin.mongos` performs a :ref:`broadcast
6691
operation<sharding-mongos-broadcast>` for queries that do *not* include the

0 commit comments

Comments
 (0)