使用聚合时的Mongo错误:排序超出了内存限制
问题描述:
当我使用聚合排序时,收到错误代码为16819
的mongo错误exceeded memory limit
.
I get the mongo error exceeded memory limit
with error code 16819
when I use aggregation sort.
我正在使用mongo 2.6.
Im using mongo 2.6.
查询如下:
db.BASE_TABLE_CREATION_ExecuteHiveScript_26_V0.aggregate([
{ "$project" : { "visitor_localdate" : 1 , "_id" : 0}},
{ "$sort" : { "visitor_localdate" : -1}}
])
答
默认情况下,MongoDB中的聚合发生在内存中,并且流水线阶段的内存限制为100 Mb.您似乎已超过此阈值.要处理大型数据集,应启用聚合管道阶段以将数据写入临时文件.为此使用 allowDiskUse
选项:
By default aggregation in MongoDB occurs in memory and pipeline stages have limit of 100 Mb RAM. Looks like you have exceeded this threshold. To handle large dataset you should enable aggregation pipeline stages to write data to temporary files. Use allowDiskUse
option for that:
db.BASE_TABLE_CREATION_ExecuteHiveScript_26_V0.aggregate([
{ "$project" : { "visitor_localdate" : 1 , "_id" : 0}},
{ "$sort" : { "visitor_localdate" : -1}}
], { "allowDiskUse" : true })