Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance gain by using bulk inserts vs regular inserts in MongoDB

What is the performance gain by using bulk inserts vs regular inserts in MongoDB and pymongo specifically. Are bulk inserts just a wrapper for regular inserts?

like image 969
dsmilkov Avatar asked May 14 '13 00:05

dsmilkov


People also ask

What is the principal implication of using a bulk write operation in MongoDB?

MongoDB provides clients the ability to perform write operations in bulk. Bulk write operations affect a single collection. MongoDB allows applications to determine the acceptable level of acknowledgement required for bulk write operations.

What is bulk insert in MongoDB?

Multiple documents can be inserted at a time in MongoDB using bulk insert operation where an array of documents is passed to the insert method as parameter.

What is the difference between insert and save in MongoDB?

But the main difference between 'save' and 'insert' command is that the 'save' command can insert or update a document whereas 'insert' only performs the insertion.

How does Upsert work in MongoDB?

Here in MongoDB, the upsert option is a Boolean value. Suppose the value is true and the documents match the specified query filter. In that case, the applied update operation will update the documents. If the value is true and no documents match the condition, this option inserts a new document into the collection.


1 Answers

Bulk inserts are no wrappers for regular inserts. A bulk insert operation contains many documents sent as a whole. It saves as many database round trips. It is much more performant since you don't have to send each document over the network separately.

like image 176
Stephane Godbillon Avatar answered Oct 23 '22 10:10

Stephane Godbillon