- Aggregation >
- Aggregation Concepts >
- Aggregation Mechanics >
- Aggregation Pipeline Limits
Aggregation Pipeline Limits¶
On this page
Aggregation operations with the aggregate
command have the
following limitations.
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.
See also
$sort and Memory Restrictions and $group Operator and Memory.