OPTIONS

Aggregation Pipeline Limits

Aggregation operations with the aggregate command have the following limitations.

Type Restrictions

The aggregation pipeline cannot operate on values of the following types: Symbol, MinKey, MaxKey, DBRef, Code, and CodeWScope.

Changed in version 2.4: Removed restriction on Binary type data. In MongoDB 2.2, the pipeline could not operate on Binary type data.

Result Size Restrictions

If the aggregate command returns a single document that contains the complete result set, the command will produce an error if the result set exceeds the BSON Document Size limit, which is currently 16 megabytes. To manage result sets that exceed this limit, the aggregate command can return result sets of any size if the command return a cursor or store the results to a collection.

Changed in version 2.6: The aggregate command can return results as a cursor or store the results in a collection, which are not subject to the size limit. The db.collection.aggregate() returns a cursor and can return result sets of any size.

Memory Restrictions

Changed in version 2.6.

Pipeline stages have a limit of 100 megabytes of RAM. If a stage exceeds this limit, MongoDB will produce an error. To allow for the handling of large datasets, use the allowDiskUse option to enable aggregation pipeline stages to write data to temporary files.