2020-09-17T03:59:21.632+0000 I COMMAND [conn28] command mail.test command: insert { insert: “test”, ordered: true, documents: 1000 } ninserted:1000 keysInserted:1000 numYields:0 reslen:44 locks:{ Global: { acquireCount: { r: 18, w: 18 } }, Database: { acquireCount: { w: 17, W: 1 } }, Collection: { acquireCount: { w: 17 } } } protocol:op_query 5ms
2020-09-17T03:59:21.972+0000 I COMMAND [conn28] command mail.$cmd command: update { update: “test”, bypassDocumentValidation: true, ordered: false, updates: 1000 } numYields:0 reslen:59 locks:{ Global: { acquireCount: { r: 4437, w: 4437 } }, Database: { acquireCount: { w: 4437 } }, Collection: { acquireCount: { w: 4437 } } } protocol:op_query 171ms
2020-09-17T03:59:22.460+0000 I COMMAND [conn28] command mail.$cmd command: update { update: “test”, bypassDocumentValidation: true, ordered: false, updates: 1000 } numYields:0 reslen:59 locks:{ Global: { acquireCount: { r: 12248, w: 12248 } }, Database: { acquireCount: { w: 12248 } }, Collection: { acquireCount: { w: 12248 } } } protocol:op_query 486ms
2020-09-17T03:59:23.255+0000 I COMMAND [conn28] command mail.$cmd command: update { update: “test”, bypassDocumentValidation: true, ordered: false, updates: 1000 } numYields:0 reslen:59 locks:{ Global: { acquireCount: { r: 20056, w: 20056 } }, Database: { acquireCount: { w: 20056 } }, Collection: { acquireCount: { w: 20056 } } } protocol:op_query 793ms
分批处理的逻辑是由 MongoDB 内部所控制的,目前应该没有办法设置,原文如下:
Each group of operations can have at most 1000 operations
. If a group exceeds this limit
, MongoDB will divide the group into smaller groups of 1000 or less. For example, if the bulk operations list consists of 2000 insert operations, MongoDB creates 2 groups, each with 1000 operations.
参考 Bulk 的说明
https://docs.mongodb.com/manual/reference/method/Bulk/index.html