Skip to content

Commit e8d47a7

Browse files
jason-price-mongodbnpentrel
authored andcommitted
DOCS-13989 disallow lookup uncorrelated pipeline caching
1 parent 1a74972 commit e8d47a7

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Starting in MongoDB 5.0, for an uncorrelated subquery in a
2+
:pipeline:`$lookup` pipeline stage containing a :pipeline:`$sample`
3+
stage, the :expression:`$sampleRate` operator, or the
4+
:expression:`$rand` operator, the subquery is always run again if
5+
repeated. Previously, depending on the subquery output size, either the
6+
subquery output was cached or the subquery was run again.

source/reference/operator/aggregation/lookup.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ In MongoDB, a correlated subquery is a :ref:`pipeline
136136
document fields from a joined collection. An uncorrelated subquery does
137137
not reference joined fields.
138138

139+
.. note::
140+
141+
.. include:: /includes/uncorrelated-subquery.rst
142+
139143
MongoDB correlated subqueries are comparable to SQL correlated
140144
subqueries, where the inner query references outer query values. An
141145
SQL uncorrelated subquery does not reference outer query values.
@@ -780,11 +784,13 @@ the ``warehouses`` collection:
780784
Perform an Uncorrelated Subquery with ``$lookup``
781785
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
782786

783-
.. versionchanged:: 3.6
787+
An aggregation pipeline :pipeline:`$lookup` stage can execute a pipeline
788+
on the joined collection, which allows uncorrelated subqueries. An
789+
uncorrelated subquery does not reference the joined document fields.
790+
791+
.. note::
784792

785-
MongoDB 3.6 adds support for executing a pipeline on the joined
786-
collection, which allows uncorrelated subqueries. An uncorrelated
787-
subquery does not reference the joined document fields.
793+
.. include:: /includes/uncorrelated-subquery.rst
788794

789795
Create a collection ``absences`` with these documents:
790796

source/release-notes/5.0.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@ stage supports :ref:`concise correlated subqueries
200200
<lookup-syntax-concise-correlated-subquery>` that improve joins between
201201
collections.
202202

203+
``$lookup`` Stage: Uncorrelated Subqueries
204+
``````````````````````````````````````````
205+
206+
.. include:: /includes/uncorrelated-subquery.rst
207+
208+
See :ref:`lookup-uncorrelated-subquery`.
209+
203210
.. _5.0-rel-notes-auditing:
204211

205212
Auditing

0 commit comments

Comments
 (0)