-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Server
Description
The page on batchSize states "Do not use a batch size of 1." and "Specifying 1 or a negative number is analogous to using the limit() method."
However, this is no longer true. Today, batchSize:1 behaves the same as any other positive batchSize.
It does not imply a limit of 1:
> db.c.find().batchSize(1).itcount() 3
And we can see that documents are returned 1 at a time:
2019-05-22T15:45:12.777-0400 I COMMAND [conn1] command test.c appName: "MongoDB Shell" command: find { find: "c", filter: {}, batchSize: 1.0, lsid: { id: UUID("e9d60651-adb1-44f8-8833-4e964306aa97") }, $db: "test" } planSummary: COLLSCAN cursorid:7412042066655548514 keysExamined:0 docsExamined:1 numYields:0 nreturned:1 reslen:120 locks:{ ParallelBatchWriter: { acquireCount: { r: 1 } }, ReplicationStateTransition: { acquireCount: { w: 1 } }, Global: { acquireCount: { r: 1 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { R: 1 } }, Mutex: { acquireCount: { r: 1 } } } protocol:op_msg 0ms 2019-05-22T15:45:12.778-0400 I COMMAND [conn1] command test.c appName: "MongoDB Shell" command: getMore { getMore: 7412042066655548514, collection: "c", batchSize: 1.0, lsid: { id: UUID("e9d60651-adb1-44f8-8833-4e964306aa97") }, $db: "test" } originatingCommand: { find: "c", filter: {}, batchSize: 1.0, lsid: { id: UUID("e9d60651-adb1-44f8-8833-4e964306aa97") }, $db: "test" } planSummary: COLLSCAN cursorid:7412042066655548514 keysExamined:0 docsExamined:1 numYields:0 nreturned:1 reslen:119 locks:{ ParallelBatchWriter: { acquireCount: { r: 1 } }, ReplicationStateTransition: { acquireCount: { w: 1 } }, Global: { acquireCount: { r: 1 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { R: 1 } }, Mutex: { acquireCount: { r: 1 } } } protocol:op_msg 0ms 2019-05-22T15:45:12.778-0400 I COMMAND [conn1] command test.c appName: "MongoDB Shell" command: getMore { getMore: 7412042066655548514, collection: "c", batchSize: 1.0, lsid: { id: UUID("e9d60651-adb1-44f8-8833-4e964306aa97") }, $db: "test" } originatingCommand: { find: "c", filter: {}, batchSize: 1.0, lsid: { id: UUID("e9d60651-adb1-44f8-8833-4e964306aa97") }, $db: "test" } planSummary: COLLSCAN cursorid:7412042066655548514 keysExamined:0 docsExamined:1 numYields:0 nreturned:1 reslen:119 locks:{ ParallelBatchWriter: { acquireCount: { r: 1 } }, ReplicationStateTransition: { acquireCount: { w: 1 } }, Global: { acquireCount: { r: 1 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { R: 1 } }, Mutex: { acquireCount: { r: 1 } } } protocol:op_msg 0ms 2019-05-22T15:45:12.779-0400 I COMMAND [conn1] command test.c appName: "MongoDB Shell" command: getMore { getMore: 7412042066655548514, collection: "c", batchSize: 1.0, lsid: { id: UUID("e9d60651-adb1-44f8-8833-4e964306aa97") }, $db: "test" } originatingCommand: { find: "c", filter: {}, batchSize: 1.0, lsid: { id: UUID("e9d60651-adb1-44f8-8833-4e964306aa97") }, $db: "test" } planSummary: COLLSCAN cursorid:7412042066655548514 keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:0 nreturned:0 reslen:94 locks:{ ParallelBatchWriter: { acquireCount: { r: 1 } }, ReplicationStateTransition: { acquireCount: { w: 1 } }, Global: { acquireCount: { r: 1 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { R: 1 } }, Mutex: { acquireCount: { r: 1 } } } protocol:op_msg 0ms