-
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 19 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 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -10,28 +10,51 @@ Bulk Operations | |||||||||||||
:depth: 2 | ||||||||||||||
:class: singlecol | ||||||||||||||
|
||||||||||||||
.. meta:: | ||||||||||||||
:keywords: insert, update, replace, code example, efficiency | ||||||||||||||
|
||||||||||||||
Overview | ||||||||||||||
-------- | ||||||||||||||
|
||||||||||||||
In this guide, you can learn how to use bulk operations in the | ||||||||||||||
MongoDB Java Driver. | ||||||||||||||
|
||||||||||||||
To perform a create, replace, update, or delete operation, | ||||||||||||||
use its corresponding method. For example, to insert one document, | ||||||||||||||
update multiple documents, and delete one document in your collection, | ||||||||||||||
use the ``insertOne()``, ``updateMany()`` and ``deleteOne()`` methods. | ||||||||||||||
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. 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. |
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.
S: 'generally' is a little vague. we can just state a fact instead
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 a single database call. You can perform bulk write operations at the following levels: |
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.
- :ref:`Collection Level <java-sync-coll-bulk-write>`: You can use the | |
- :ref:`Collection <java-sync-coll-bulk-write>`: You can use the |
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.
S:
single collection. This method groups write operations together by the kind | |
of operation. For example, ``MongoCollection.bulkWrite()`` puts multiple update | |
single collection. In this method, each kind of write operation requires one | |
database call. For example, ``MongoCollection.bulkWrite()`` puts multiple update |
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.
S: maybe a little clearer
of operation. For example, ``MongoCollection.bulkWrite()`` puts multiple update | |
operations in the same call, but makes two calls to the database for an insert | |
operation and a replace operation. | |
of operation. For example, to perform two update operations, two insert | |
operations, and two replace operations, the client performs three database | |
calls. |
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.
I left mostly as is because I wasn't sure if this made it clearer - if you feel strongly about this I can change, also happy to discuss further
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.
- :ref:`Client Level <java-sync-client-bulk-write>`: When running {+mdb-server+} | |
- :ref:`Client <java-sync-client-bulk-write>`: When running {+mdb-server+} |
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.
- :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 | |
- :ref:`Client Level <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 |
mayaraman19 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
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.
This method groups multiple kinds of write operations into one call. | |
This method performs all write operations in one database call. |
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.
S: specify bulk write
Bulk operations consist of many write operations. To perform a bulk operation | |
Bulk write operations contain one or more write operations. To perform a bulk write 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.
represents any of the write operations. | |
represents a write 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.
S:
The ``MongoCollection.bulkWrite()`` method splits operations of different kinds into | |
different batches. For example, when you pass ``DeleteOneModel``, | |
The ``MongoCollection.bulkWrite()`` method performs each kind of write operation | |
in a separate batch. 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.
``DeleteManyModel``, and ``ReplaceOneModel`` operations to the method, the method | |
``DeleteManyModel``, and ``ReplaceOneModel`` objects to the method, the method |
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.
``DeleteManyModel``, and ``ReplaceOneModel`` operations to the method, the method | |
``DeleteManyModel``, and ``ReplaceOneModel`` operations to the method, it |
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.
S:
splits the delete operations into one batch and the replace operation | |
into another. During this process, the client might reorder operations for | |
creates two batches: one for the delete operations and one for the replace operation. | |
During this process, the client might reorder operations for |
between these two sentences, maybe mention that a batch = one database call (unless that's somewhere else on the page)
mayaraman19 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
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.
S: put this last line in a note admonition and link to the section on ordering
mayaraman19 marked this conversation as resolved.
Show resolved
Hide resolved
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.
S: if someone jumps straight to this section, they might not see that this line is intended to compare client bulk writes to collection bulk writes.
to multiple databases and collections in the same cluster. The ``MongoClient.bulkWrite()`` | |
method does not split different kinds of operations into different batches. | |
to multiple databases and collections in the same cluster. The ``MongoClient.bulkWrite()`` | |
method performs all write operation in a single batch. |
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.
S: unfortunately, i think it's worth repeating the info from earlier in the page just to users don't have to read earlier sections if they don't need to. if you have a lot of repeated content, you can always put it in an includes
directive 😎
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.
honestly, I'm not sure how much this information is relevant so I will remove it 👍
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 can construct instances of ``ClientNamespacedWriteModel`` using the following | |
You can construct instances of the ``ClientNamespacedWriteModel`` class by using the following |
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.
S: would use this pattern for each method and delete the following paragraph
- ``insertOne()`` | |
- ``ClientNamespacedWriteModel.insertOne()``: Constructs a ``ClientNamespacedInsertOneModel`` instance. |
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 comprehensiveness and clarity, we probably want to specify which methods take what. you could give each method its own subsection, or add a parameter list/table for each one
Uh oh!
There was an error while loading. Please reload this page.