File tree Expand file tree Collapse file tree 3 files changed +22
-18
lines changed
reference/operator/aggregation Expand file tree Collapse file tree 3 files changed +22
-18
lines changed Original file line number Diff line number Diff line change @@ -228,10 +228,7 @@ Read Preference and Transactions
228228Additional Considerations
229229-------------------------
230230
231- For :doc:`aggregation pipeline </core/aggregation-pipeline>`
232- operations that include the :pipeline:`$out` or :pipeline:`$merge`
233- stages, the pipeline runs on the :term:`primary` member regardless of
234- read preference setting.
231+ .. include:: /includes/merge-and-read-preference.rst
235232
236233For :dbcommand:`mapReduce` operations, only "inline"
237234:dbcommand:`mapReduce` operations that do not write data support read
Original file line number Diff line number Diff line change 1+ Consider the following points when using :pipeline: `$merge ` or
2+ :pipeline: `$out ` stages in an :ref: `aggregation pipeline
3+ <aggregation-pipeline>`:
4+
5+ - Starting in MongoDB 5.0, pipelines with a ``$merge `` stage can run on
6+ replica set :term: `secondary ` nodes if all the nodes in the cluster
7+ have the :ref: `featureCompatibilityVersion <view-fcv >` set to ``5.0 ``
8+ or higher and the :ref: `read preference <read-preference >`
9+ allows secondary reads.
10+
11+ - ``$merge `` and ``$out `` stages run on secondary nodes, but write
12+ operations are sent to the :term: `primary ` node.
13+
14+ - Not all driver versions support ``$merge `` operations sent to
15+ the secondary nodes. For details, see the :driver: `driver </> `
16+ documentation.
17+
18+ - In earlier MongoDB versions, pipelines with ``$out `` or ``$merge ``
19+ stages always run on the primary node and read preference isn't
20+ considered.
Original file line number Diff line number Diff line change @@ -40,20 +40,7 @@ Definition
4040 - Can output to the same collection that is being aggregated. For more
4141 information, see :ref:`merge-behavior-same-collection`.
4242
43- - Pipelines with the :pipeline:`$merge` stage can run on
44- replica set secondary nodes if all the nodes in cluster have
45- :ref:`featureCompatibilityVersion <view-fcv>` set
46- to ``5.0`` or higher and the :doc:`/core/read-preference`
47- allows secondary reads.
48-
49- - Read operations of the :pipeline:`$merge` statement are sent to
50- secondary nodes, while the write operations occur only on the
51- primary node.
52-
53- - Not all driver versions support targeting of :pipeline:`$merge`
54- operations to replica set secondary nodes. Check your
55- :driver:`driver </>` documentation to see when your driver added support
56- for :pipeline:`$merge` read operations running on secondary nodes.
43+ - .. include:: /includes/merge-and-read-preference.rst
5744
5845 - Creates a new collection if the output collection does not already
5946 exist.
You can’t perform that action at this time.
0 commit comments