Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default batch size in aggregate command in MongoDB

From aggregate command doucumentation`:

To indicate a cursor with the default batch size, specify cursor: {}.

However, I haven't found the value of such defaul or how to find it (maybe using a mongo admin command).

How to find such value?

like image 583
fgalan Avatar asked Jan 28 '23 12:01

fgalan


1 Answers

From the docs:

The MongoDB server returns the query results in batches. The amount of data in the batch will not exceed the maximum BSON document size.

New in version 3.4: Operations of type find(), aggregate(), listIndexes, and listCollections return a maximum of 16 megabytes per batch. batchSize() can enforce a smaller limit, but not a larger one.

find() and aggregate() operations have an initial batch size of 101 documents by default. Subsequent getMore operations issued against the resulting cursor have no default batch size, so they are limited only by the 16 megabyte message size.

So, the default for the first batch is 101 documents, the batch size for subsequent getMore() calls is undetermined but cannot exceed 16 megabytes.

like image 194
glytching Avatar answered Mar 13 '23 05:03

glytching