简体   繁体   中英

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?

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.

If I'm not entirely wrong, I think it's 101 for aggregation pipeline.

See here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM