Skip to content

DOCS-775 limit on multiple expressions #970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 4 additions & 0 deletions source/includes/fact-limits-multiple-in-expressions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
When using two or more :operator:`$in` expressions, the product of the
number of **distinct** elements in the :operator:`$in` arrays must be
less than 4000000. Otherwise, MongoDB will throw an exception of
``"combinatorial limit of $in partitioning of result set exceeded"``.
5 changes: 5 additions & 0 deletions source/reference/limits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ Operations

.. include:: /includes/fact-geometry-hemisphere-limitation.rst

.. _limit-multiple-in:
.. limit:: Combination Limit with Multiple $in Expressions

.. include:: /includes/fact-limits-multiple-in-expressions.rst

Naming Restrictions
~~~~~~~~~~~~~~~~~~~

Expand Down
23 changes: 15 additions & 8 deletions source/reference/operator/in.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ $in
:operator:`$in` selects the documents where the ``field`` value
equals any value in the specified array (e.g. ``<value1>``,
``<value2>``, etc.)

Consider the following example:

.. code-block:: javascript

db.inventory.find( { qty: { $in: [ 5, 15 ] } } )
Expand All @@ -24,23 +24,30 @@ $in
:operator:`$or` operator, choose the :operator:`$in` operator rather
than the :operator:`$or` operator when performing equality checks on
the same field.

If the ``field`` holds an array, then the :operator:`$in` operator
selects the documents whose ``field`` holds an array that contains
at least one element that matches a value in the specified array
(e.g. ``<value1>``, ``<value2>``, etc.)

Consider the following example:

.. code-block:: javascript

db.inventory.update( { tags: { $in: ["appliances", "school"] } }, { $set: { sale:true } } )

db.inventory.update(
{ tags: { $in: ["appliances", "school"] } },
{ $set: { sale:true } }
)

This :method:`update() <db.collection.update()>` operation will set
the ``sale`` field value in the ``inventory`` collection where the
``tags`` field holds an array with at least one element matching an
element in the array ``["appliances", "school"]``.


.. note::

.. include:: /includes/fact-limits-multiple-in-expressions.rst

.. seealso::

:method:`find() <db.collection.find()>`, :method:`update()
Expand Down