On this page本页内容
Tip
Starting in version 3.2, MongoDB also provides the db.collection.bulkWrite()
method for performing bulk write operations.
db.collection.
initializeUnorderedBulkOp
()¶mongo
Shell Method
This page documents the 本页记录了mongo
shell method, and does not refer to the MongoDB Node.js driver (or any other driver) method. mongo
shell方法,未提及MongoDB Node.js驱动程序(或任何其他驱动程序)方法。For corresponding MongoDB driver API, refer to your specific MongoDB driver documentation instead.有关相应的MongoDB驱动程序API,请参阅特定的MongoDB驱动程序文档。
Initializes and returns a new Bulk()
operations builder for a collection. The builder constructs an unordered list of write operations that MongoDB executes in bulk.
With an unordered operations list, MongoDB can execute in parallel the write operations in the list and in any order. If the order of operations matter, use db.collection.initializeOrderedBulkOp()
instead.
When executing an unordered
list of operations, MongoDB groups the operations. With an unordered bulk operation, the operations in the list may be reordered to increase performance. As such, applications should not depend on the ordering when performing unordered
bulk operations.
Each group of operations can have at most 1000 operations
. If a group exceeds this limit
, MongoDB will divide the group into smaller groups of 1000 or less. For example, if the bulk operations list consists of 2000 insert operations, MongoDB creates 2 groups, each with 1000 operations.
The sizes and grouping mechanics are internal performance details and are subject to change in future versions.
To see how the operations are grouped for a bulk operation execution, call Bulk.getOperations()
after the execution.
If an error occurs during the processing of one of the write operations, MongoDB will continue to process remaining write operations in the list.