@@ -17,10 +17,8 @@ Definition
17
17
18
18
.. method:: cursor.batchSize(size)
19
19
20
-
21
20
.. include:: /includes/fact-mongosh-shell-method.rst
22
21
23
-
24
22
Specifies the
25
23
number of documents to return in each batch of the response from the
26
24
MongoDB instance. In most cases, modifying the batch size will
@@ -29,34 +27,36 @@ Definition
29
27
single batch.
30
28
31
29
The :method:`~cursor.batchSize()` method takes the
32
- following parameter:
33
-
30
+ following field:
34
31
35
32
.. list-table::
36
33
:header-rows: 1
37
34
:widths: 20 20 80
38
35
39
- * - Parameter
40
-
36
+ * - Field
41
37
- Type
42
-
43
38
- Description
44
39
45
40
* - ``size``
46
-
47
41
- integer
48
-
49
- - The number of documents to return per batch.
42
+ - The initial number of documents to return for a batch. The
43
+ default initial batch size is 101 documents. Subsequent
44
+ batches are 16 megabytes. The default applies to drivers and
45
+ Mongo Shell. For details, see :ref:`cursor-batches`.
50
46
51
47
Example
52
48
-------
53
49
54
- The following example sets the batch size for the results of a query
55
- (i.e. :method:`~db.collection.find()`) to ``10``. The
56
- :method:`~cursor.batchSize()` method does not change the
57
- output in :binary:`~bin.mongosh`, which, by default, iterates over the
58
- first 20 documents.
50
+ The following example sets ``batchSize`` for the results of a query
51
+ (specifically, :method:`~db.collection.find()`) to ``10``:
59
52
60
53
.. code-block:: javascript
61
54
62
55
db.inventory.find().batchSize(10)
56
+
57
+ Learn More
58
+ ----------
59
+
60
+ - :ref:`cursor-batches`
61
+ - :method:`cursor.next()`
62
+ - :dbcommand:`getMore`
0 commit comments