Skip to content

Commit 9dfb64a

Browse files
DOCSP-51971-clarify-insertMany-limit-main-backport (#12984)
1 parent df4aa47 commit 9dfb64a

File tree

4 files changed

+140
-60
lines changed

4 files changed

+140
-60
lines changed

content/manual/manual/source/reference/method/db.collection.insertMany.txt

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,9 @@ syntax:
8484
* - ``document``
8585

8686
- document
87-
87+
8888
- An array of documents to insert into the collection.
89-
90-
91-
89+
9290
* - ``writeConcern``
9391

9492
- document
@@ -111,27 +109,48 @@ syntax:
111109
Behaviors
112110
---------
113111

114-
Given an array of documents, :method:`~db.collection.insertMany()`
115-
inserts each document in the array into the collection.
112+
Given an array of documents, ``insertMany()`` inserts each document in
113+
the array into the collection. There is no limit to the number of
114+
documents you can specify in the array.
116115

117116
Execution of Operations
118117
~~~~~~~~~~~~~~~~~~~~~~~
119118

120119
By default, documents are inserted in the order they are provided.
121120

122-
If ``ordered`` is set to ``true`` and an insert fails, the server does
123-
not continue inserting records.
121+
- If ``ordered`` is set to ``true`` and an insert fails, the server does
122+
not continue inserting records.
124123

125-
If ``ordered`` is set to ``false`` and an insert fails, the server
126-
continues inserting records. Documents may be reordered by
127-
:binary:`~bin.mongod` to increase performance. Applications should not
128-
depend on ordering of inserts if using an unordered
129-
:method:`~db.collection.insertMany()`.
130-
131-
.. include:: /includes/fact-bulkwrite-operation-batches.rst
124+
- If ``ordered`` is set to ``false`` and an insert fails, the server
125+
continues inserting records. Documents may be reordered by
126+
:binary:`~bin.mongod` to increase performance. Applications should not
127+
depend on ordering of inserts if using an unordered ``insertMany()``.
132128

133129
.. include:: /includes/fact-bulk-operation-sharded-cluster.rst
134130

131+
Batching
132+
~~~~~~~~
133+
134+
The driver batches documents specified in the ``insertMany()`` array
135+
according to the :limit:`maxWriteBatchSize <Write Command Batch Limit
136+
Size>`, which is 100,000 and cannot be modified. For example, if the
137+
``insertMany()`` operation contains 250,000 documents, the driver
138+
creates three batches: two with 100,000 documents and one with 50,000
139+
documents.
140+
141+
.. note::
142+
143+
The driver only performs batching when using the high-level API. If
144+
you use :method:`db.runCommand()` directly (for example, when writing
145+
a driver), MongoDB throws an error when attempting to execute a write
146+
batch that exceeds the ``maxWriteBatchSize`` limit.
147+
148+
If the error report for a single batch grows too large, MongoDB
149+
truncates all remaining error messages. If there are at least two error
150+
messages with size greater than ``1MB``, those messages are truncated.
151+
152+
The sizes and grouping mechanics are internal performance details and
153+
are subject to change in future versions.
135154

136155
Collection Creation
137156
~~~~~~~~~~~~~~~~~~~
@@ -459,4 +478,4 @@ This operation returns:
459478

460479
.. seealso::
461480

462-
:data:`WriteResult.writeConcernError`
481+
:data:`WriteResult.writeConcernError`

content/manual/rapid/source/reference/method/db.collection.insertMany.txt

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,9 @@ syntax:
8484
* - ``document``
8585

8686
- document
87-
87+
8888
- An array of documents to insert into the collection.
89-
90-
91-
89+
9290
* - ``writeConcern``
9391

9492
- document
@@ -111,27 +109,48 @@ syntax:
111109
Behaviors
112110
---------
113111

114-
Given an array of documents, :method:`~db.collection.insertMany()`
115-
inserts each document in the array into the collection.
112+
Given an array of documents, ``insertMany()`` inserts each document in
113+
the array into the collection. There is no limit to the number of
114+
documents you can specify in the array.
116115

117116
Execution of Operations
118117
~~~~~~~~~~~~~~~~~~~~~~~
119118

120119
By default, documents are inserted in the order they are provided.
121120

122-
If ``ordered`` is set to ``true`` and an insert fails, the server does
123-
not continue inserting records.
121+
- If ``ordered`` is set to ``true`` and an insert fails, the server does
122+
not continue inserting records.
124123

125-
If ``ordered`` is set to ``false`` and an insert fails, the server
126-
continues inserting records. Documents may be reordered by
127-
:binary:`~bin.mongod` to increase performance. Applications should not
128-
depend on ordering of inserts if using an unordered
129-
:method:`~db.collection.insertMany()`.
130-
131-
.. include:: /includes/fact-bulkwrite-operation-batches.rst
124+
- If ``ordered`` is set to ``false`` and an insert fails, the server
125+
continues inserting records. Documents may be reordered by
126+
:binary:`~bin.mongod` to increase performance. Applications should not
127+
depend on ordering of inserts if using an unordered ``insertMany()``.
132128

133129
.. include:: /includes/fact-bulk-operation-sharded-cluster.rst
134130

131+
Batching
132+
~~~~~~~~
133+
134+
The driver batches documents specified in the ``insertMany()`` array
135+
according to the :limit:`maxWriteBatchSize <Write Command Batch Limit
136+
Size>`, which is 100,000 and cannot be modified. For example, if the
137+
``insertMany()`` operation contains 250,000 documents, the driver
138+
creates three batches: two with 100,000 documents and one with 50,000
139+
documents.
140+
141+
.. note::
142+
143+
The driver only performs batching when using the high-level API. If
144+
you use :method:`db.runCommand()` directly (for example, when writing
145+
a driver), MongoDB throws an error when attempting to execute a write
146+
batch that exceeds the ``maxWriteBatchSize`` limit.
147+
148+
If the error report for a single batch grows too large, MongoDB
149+
truncates all remaining error messages. If there are at least two error
150+
messages with size greater than ``1MB``, those messages are truncated.
151+
152+
The sizes and grouping mechanics are internal performance details and
153+
are subject to change in future versions.
135154

136155
Collection Creation
137156
~~~~~~~~~~~~~~~~~~~
@@ -459,4 +478,4 @@ This operation returns:
459478

460479
.. seealso::
461480

462-
:data:`WriteResult.writeConcernError`
481+
:data:`WriteResult.writeConcernError`

content/manual/v6.0/source/reference/method/db.collection.insertMany.txt

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,9 @@ syntax:
8484
* - ``document``
8585

8686
- document
87-
87+
8888
- An array of documents to insert into the collection.
89-
90-
91-
89+
9290
* - ``writeConcern``
9391

9492
- document
@@ -111,23 +109,48 @@ syntax:
111109
Behaviors
112110
---------
113111

114-
Given an array of documents, :method:`~db.collection.insertMany()`
115-
inserts each document in the array into the collection.
112+
Given an array of documents, ``insertMany()`` inserts each document in
113+
the array into the collection. There is no limit to the number of
114+
documents you can specify in the array.
116115

117116
Execution of Operations
118117
~~~~~~~~~~~~~~~~~~~~~~~
119118

120119
By default documents are inserted in order.
121120

122-
If ``ordered`` is set to false, documents are inserted in an unordered
123-
format and may be reordered by :binary:`~bin.mongod` to increase performance.
124-
Applications should not depend on ordering of inserts if using an unordered
125-
:method:`~db.collection.insertMany()`.
121+
- If ``ordered`` is set to ``true`` and an insert fails, the server does
122+
not continue inserting records.
126123

127-
.. include:: /includes/fact-bulkwrite-operation-batches.rst
124+
- If ``ordered`` is set to ``false`` and an insert fails, the server
125+
continues inserting records. Documents may be reordered by
126+
:binary:`~bin.mongod` to increase performance. Applications should not
127+
depend on ordering of inserts if using an unordered ``insertMany()``.
128128

129129
.. include:: /includes/fact-bulk-operation-sharded-cluster.rst
130130

131+
Batching
132+
~~~~~~~~
133+
134+
The driver batches documents specified in the ``insertMany()`` array
135+
according to the :limit:`maxWriteBatchSize <Write Command Batch Limit
136+
Size>`, which is 100,000 and cannot be modified. For example, if the
137+
``insertMany()`` operation contains 250,000 documents, the driver
138+
creates three batches: two with 100,000 documents and one with 50,000
139+
documents.
140+
141+
.. note::
142+
143+
The driver only performs batching when using the high-level API. If
144+
you use :method:`db.runCommand()` directly (for example, when writing
145+
a driver), MongoDB throws an error when attempting to execute a write
146+
batch that exceeds the ``maxWriteBatchSize`` limit.
147+
148+
If the error report for a single batch grows too large, MongoDB
149+
truncates all remaining error messages. If there are at least two error
150+
messages with size greater than ``1MB``, those messages are truncated.
151+
152+
The sizes and grouping mechanics are internal performance details and
153+
are subject to change in future versions.
131154

132155
Collection Creation
133156
~~~~~~~~~~~~~~~~~~~
@@ -455,4 +478,4 @@ This operation returns:
455478

456479
.. seealso::
457480

458-
:data:`WriteResult.writeConcernError`
481+
:data:`WriteResult.writeConcernError`

content/manual/v7.0/source/reference/method/db.collection.insertMany.txt

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,9 @@ syntax:
8484
* - ``document``
8585

8686
- document
87-
87+
8888
- An array of documents to insert into the collection.
89-
90-
91-
89+
9290
* - ``writeConcern``
9391

9492
- document
@@ -111,27 +109,48 @@ syntax:
111109
Behaviors
112110
---------
113111

114-
Given an array of documents, :method:`~db.collection.insertMany()`
115-
inserts each document in the array into the collection.
112+
Given an array of documents, ``insertMany()`` inserts each document in
113+
the array into the collection. There is no limit to the number of
114+
documents you can specify in the array.
116115

117116
Execution of Operations
118117
~~~~~~~~~~~~~~~~~~~~~~~
119118

120119
By default, documents are inserted in the order they are provided.
121120

122-
If ``ordered`` is set to ``true`` and an insert fails, the server does
123-
not continue inserting records.
121+
- If ``ordered`` is set to ``true`` and an insert fails, the server does
122+
not continue inserting records.
124123

125-
If ``ordered`` is set to ``false`` and an insert fails, the server
126-
continues inserting records. Documents may be reordered by
127-
:binary:`~bin.mongod` to increase performance. Applications should not
128-
depend on ordering of inserts if using an unordered
129-
:method:`~db.collection.insertMany()`.
130-
131-
.. include:: /includes/fact-bulkwrite-operation-batches.rst
124+
- If ``ordered`` is set to ``false`` and an insert fails, the server
125+
continues inserting records. Documents may be reordered by
126+
:binary:`~bin.mongod` to increase performance. Applications should not
127+
depend on ordering of inserts if using an unordered ``insertMany()``.
132128

133129
.. include:: /includes/fact-bulk-operation-sharded-cluster.rst
134130

131+
Batching
132+
~~~~~~~~
133+
134+
The driver batches documents specified in the ``insertMany()`` array
135+
according to the :limit:`maxWriteBatchSize <Write Command Batch Limit
136+
Size>`, which is 100,000 and cannot be modified. For example, if the
137+
``insertMany()`` operation contains 250,000 documents, the driver
138+
creates three batches: two with 100,000 documents and one with 50,000
139+
documents.
140+
141+
.. note::
142+
143+
The driver only performs batching when using the high-level API. If
144+
you use :method:`db.runCommand()` directly (for example, when writing
145+
a driver), MongoDB throws an error when attempting to execute a write
146+
batch that exceeds the ``maxWriteBatchSize`` limit.
147+
148+
If the error report for a single batch grows too large, MongoDB
149+
truncates all remaining error messages. If there are at least two error
150+
messages with size greater than ``1MB``, those messages are truncated.
151+
152+
The sizes and grouping mechanics are internal performance details and
153+
are subject to change in future versions.
135154

136155
Collection Creation
137156
~~~~~~~~~~~~~~~~~~~
@@ -459,4 +478,4 @@ This operation returns:
459478

460479
.. seealso::
461480

462-
:data:`WriteResult.writeConcernError`
481+
:data:`WriteResult.writeConcernError`

0 commit comments

Comments
 (0)