@@ -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:
111109Behaviors
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
117116Execution of Operations
118117~~~~~~~~~~~~~~~~~~~~~~~
119118
120119By 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
136155Collection Creation
137156~~~~~~~~~~~~~~~~~~~
@@ -459,4 +478,4 @@ This operation returns:
459478
460479.. seealso::
461480
462- :data:`WriteResult.writeConcernError`
481+ :data:`WriteResult.writeConcernError`
0 commit comments