On this page本页内容
Aggregation operations with the 使用aggregate命令的聚合操作具有以下限制。aggregate
command have the following limitations.
Changed in version 3.6:在版本3.6中更改:MongoDB 3.6 removes the option for the MongoDB 3.6删除了aggregate
command to return its results as a single document.aggregate
命令将结果作为单个文档返回的选项。
The aggregate
command can return either a cursor or store the results in a collection.aggregate
命令可以返回游标,也可以将结果存储在集合中。When returning a cursor or storing the results in a collection, each document in the result set is subject to the 返回游标或将结果存储在集合中时,结果集中的每个文档都受BSON文档大小限制(当前为16兆字节)的约束;如果任何单个文档超过BSON文档大小限制,则该命令将产生错误。
BSON Document Size
limit, currently 16 megabytes; if any single document that exceeds the BSON Document Size
limit, the command will produce an error.The limit only applies to the returned documents; during the pipeline processing, the documents may exceed this size.此限制仅适用于返回的文档;在流水线处理过程中,文档可能超过此大小。The db.collection.aggregate()方法默认返回一个游标。db.collection.aggregate()
method returns a cursor by default.
Pipeline stages have a limit of 100 megabytes of RAM.管道级的RAM限制为100兆字节。If a stage exceeds this limit, MongoDB will produce an error.如果某个阶段超过此限制,MongoDB将产生一个错误。To allow for the handling of large datasets, use the 要允许处理大型数据集,请使用allowDiskUse
option to enable aggregation pipeline stages to write data to temporary files.allowDiskUse
选项启用聚合管道阶段以将数据写入临时文件。
Changed in version 3.4.在版本3.4中更改。
The $graphLookup
stage must stay within the 100 megabyte memory limit.$graphLookup
阶段必须保持在100MB内存限制内。If 如果为allowDiskUse: true
is specified for the aggregate()
operation, the $graphLookup
stage ignores the option.aggregate()
操作指定allowDiskUse:true
,$graphLookup
阶段将忽略该选项。If there are other stages in the 如果aggregate()
operation, allowDiskUse: true
option is in effect for these other stages.aggregate()
操作中还有其他阶段,则allowDiskUse: true
选项对这些其他阶段有效。
Starting in MongoDB 4.2, the profiler log messages and diagnostic log messages includes a 从MongoDB 4.2开始,如果任何聚合阶段由于内存限制将数据写入临时文件,那么profiler日志消息和诊断日志消息将包含usedDisk
indicator if any aggregation stage wrote data to temporary files due to memory restrictions.usedDisk
指示符。
See also另请参阅
$sort and Memory Restrictions and $group Operator and Memory.$sort和内存限制以及$group运算符和内存。