Does BulkWrite respect BSONObj size of a batch?

230 views
Skip to first unread message

Alex K

unread,
Feb 23, 2018, 3:19:54 AM2/23/18
to mongodb-user
Hello,

The BulkWrite and BulkWriteAsync methods take a variable number of WriteModel<> instances and send them to the server in the fewest possible number of batches. The size of a batch is limited by the maximum document size and each batch must consist of the same kind of write operations (i.e. deletes, inserts or updates).

Does that mean that BulkWrite methods should not send batches bigger than 16Mb or that is beyond driver control and should be managed / limited by external methods?

Thanks!
Alex 

Wan Bachtiar

unread,
Mar 28, 2018, 10:48:54 PM3/28/18
to mongodb-user

Does that mean that BulkWrite methods should not send batches bigger than 16Mb or that is beyond driver control and should be managed / limited by external methods?

Hi Alex,

The 16MB limit is the maximum size of the current BSON document spec that could be sent over the wire.

The drivers would have taken this into account when communicating to the server, so you don’t have to do a count on the client side. The batch operations will be managed based on the the 16MB document size or the batch size limit. For MongoDB C# driver, see also SizeLimitingBatchableSourceSerializer.cs.

See also Bulk() for more information.

Regards,
Wan.

Reply all
Reply to author
Forward
0 new messages