diff --git a/source/includes/fact-limits-multiple-in-expressions.rst b/source/includes/fact-limits-multiple-in-expressions.rst new file mode 100644 index 00000000000..1d7cdb99796 --- /dev/null +++ b/source/includes/fact-limits-multiple-in-expressions.rst @@ -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"``. diff --git a/source/reference/limits.txt b/source/reference/limits.txt index 35e2645c2ec..551462a0e65 100644 --- a/source/reference/limits.txt +++ b/source/reference/limits.txt @@ -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 ~~~~~~~~~~~~~~~~~~~ diff --git a/source/reference/operator/in.txt b/source/reference/operator/in.txt index 0cbd65f7afc..1a608b3bc41 100644 --- a/source/reference/operator/in.txt +++ b/source/reference/operator/in.txt @@ -11,9 +11,9 @@ $in :operator:`$in` selects the documents where the ``field`` value equals any value in the specified array (e.g. ````, ````, etc.) - + Consider the following example: - + .. code-block:: javascript db.inventory.find( { qty: { $in: [ 5, 15 ] } } ) @@ -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. ````, ````, 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() ` 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() `, :method:`update()