使用聚合时的 Mongo 错误:排序超出内存限制 [英] Mongo error when using aggregation: sort exceeded memory limit

查看:9
本文介绍了使用聚合时的 Mongo 错误:排序超出内存限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用聚合排序时,我得到了 mongo 错误 exceeded memory limit 错误代码 16819.

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 RAM.看起来你已经超过了这个阈值.要处理大型数据集,您应该启用聚合管道阶段以将数据写入临时文件.使用 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 })

这篇关于使用聚合时的 Mongo 错误:排序超出内存限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆