|
When creating an unordered bulk operation containing operations of different kinds they are not compiled into bigger batches but simply sent in the order they arrive.
For example the sequence:
insert()
|
update()
|
insert()
|
update()
|
insert()
|
would be sent in 5 unique batches each containing one operation instead of two larger ones.
var batch = coll.initializeUnorderedBulkOp();
|
for (var i=0;i<5001;i++) {
|
batch.insert({_id:i});
|
batch.find({c:i}).removeOne();
|
}
|
result = batch.execute();
|
would result in 10000 commands being sent to the server instead of the necessary 10. Most users probably won't encounter this but it's not pretty. Essentially the unordered implementation behaves like the ordered except that execution does not terminate on server errors.
|