-
Notifications
You must be signed in to change notification settings - Fork 43
DOCSP-41769: Improved bulk write API #590
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
Changes from 4 commits
72b9e73
09d5786
161ffec
9d37fac
5e577ba
78d26c0
db24b1e
56413a0
7308593
c30dacd
08baf89
fa4ff13
578cb8d
1c94b5c
ad5ea28
d9a33d9
02b1720
ef63a45
1cfd451
7110a7f
68e6074
9934475
f43f5c9
605cf7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -21,40 +21,45 @@ MongoDB Java Driver. | |||||||||
|
||||||||||
To perform a single create, replace, update, or delete operation, you can use | ||||||||||
the corresponding method. For example, to insert one document and replace one | ||||||||||
document, you can use the ``insertOne()`` and ``replaceOne()`` methods. In this | ||||||||||
case, the ``MongoClient`` makes a call to the database for each operation. | ||||||||||
document, you can use the ``insertOne()`` and ``replaceOne()`` methods. When you | ||||||||||
use these methods, the ``MongoClient`` makes one call to the database for each operation. | ||||||||||
|
||||||||||
Generally, you can reduce the number of calls to the database by using bulk write | ||||||||||
operations. You can perform bulk write operations at the following levels: | ||||||||||
By using a bulk write operation, you can perform multiple write operations in | ||||||||||
fewer database calls. You can perform bulk write operations at the following levels: | ||||||||||
|
||||||||||
- :ref:`Collection Level <java-sync-coll-bulk-write>`: You can use the | ||||||||||
- :ref:`Collection <java-sync-coll-bulk-write>`: You can use the | ||||||||||
``MongoCollection.bulkWrite()`` method to perform bulk write operations on a | ||||||||||
single collection. This method groups write operations together by the kind | ||||||||||
of operation. For example, ``MongoCollection.bulkWrite()`` puts multiple update | ||||||||||
operations in the same call, but makes two calls to the database for an insert | ||||||||||
single collection. In this method, each kind of write operation requires at | ||||||||||
least one database call. For example, ``MongoCollection.bulkWrite()`` puts multiple update | ||||||||||
operations in one call, but makes two separate calls to the database for an insert | ||||||||||
operation and a replace operation. | ||||||||||
|
||||||||||
- :ref:`Client Level <java-sync-client-bulk-write>`: When running {+mdb-server+} | ||||||||||
version 8.0 or later, you can use the ``MongoClient.bulkWrite()`` method to perform | ||||||||||
bulk write operations on multiple collections and databases in the same cluster. | ||||||||||
This method groups multiple kinds of write operations into one call. | ||||||||||
- :ref:`Client <java-sync-client-bulk-write>`: If your application connects to | ||||||||||
{+mdb-server+} version 8.0 or later, you can use the ``MongoClient.bulkWrite()`` | ||||||||||
method to perform bulk write operations on multiple collections and databases | ||||||||||
in the same cluster. This method performs all write operations | ||||||||||
in one database call. | ||||||||||
|
||||||||||
.. _java-sync-coll-bulk-write: | ||||||||||
|
||||||||||
Collection Bulk Write | ||||||||||
--------------------- | ||||||||||
|
||||||||||
Bulk operations consist of many write operations. To perform a bulk operation | ||||||||||
at the collection level, pass a ``List`` of ``WriteModel`` documents to the | ||||||||||
``MongoCollection.bulkWrite()`` method. A ``WriteModel`` is a model that | ||||||||||
represents any of the write operations. | ||||||||||
Bulk write operations contain one or more write operations. To perform a bulk | ||||||||||
write operation at the collection level, pass a ``List`` of ``WriteModel`` | ||||||||||
documents to the ``MongoCollection.bulkWrite()`` method. A ``WriteModel`` is a | ||||||||||
model that represents a write operation. | ||||||||||
|
||||||||||
The ``MongoCollection.bulkWrite()`` method splits operations of different kinds into | ||||||||||
different batches. For example, when you pass ``DeleteOneModel``, | ||||||||||
``DeleteManyModel``, and ``ReplaceOneModel`` operations to the method, the method | ||||||||||
splits the delete operations into one batch and the replace operation | ||||||||||
into another. During this process, the client might reorder operations for | ||||||||||
efficiency if the bulk operation is not ordered. | ||||||||||
The ``MongoCollection.bulkWrite()`` method performs each kind of write | ||||||||||
operations in a separate call. For example, when you pass ``DeleteOneModel``, | ||||||||||
|
The ``MongoCollection.bulkWrite()`` method performs each kind of write | |
operations in a separate call. For example, when you pass ``DeleteOneModel``, | |
The ``MongoCollection.bulkWrite()`` method performs each kind of write | |
operation in a separate database call. For example, when you pass ``DeleteOneModel``, |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could probably say 'creates two batches' or 'performs two calls', but 'creates two calls' is confusing
``DeleteManyModel``, and ``ReplaceOneModel`` objects to the method, it creates | |
two calls: one for the delete operations and one for the replace operation. | |
``DeleteManyModel``, and ``ReplaceOneModel`` objects to the method, it performs | |
two calls: one for the delete operations and one for the replace operation. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the client splits operations into calls, it might reorder operations for | |
When the client splits operations into separate database calls, it might reorder operations for |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all of these parameters, removes 'defines which' or 'defines a' and then capitalize the first letter (e.g., 'Database and collection to write to')
https://www.mongodb.com/docs/meta/style-guide/style/lists/#list-items
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Creates a model to update at most one document in the ``namespace`` | |
- Creates a model to update the first document in the ``namespace`` |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of ``update`` or ``updatePipeline`` must be specified. | |
You must pass a value for either the ``update`` or ``updatePipeline`` parameter. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of ``update`` or ``updatePipeline`` must be specified. | |
You must pass a value for either the ``update`` or ``updatePipeline`` parameter. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Creates a model to replace at most one document in the ``namespace`` that | |
- Creates a model to replace the first document in the ``namespace`` that |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Creates a model to delete at most one document in the ``namespace`` that | |
- Creates a model to delete the first document in the ``namespace`` that |
Uh oh!
There was an error while loading. Please reload this page.