Exceeded memory limit for $group, but didn't allow external sort. Pass allowDisk

原语句:

db.carMongoDTO.aggregate({‘$group’:{‘_id’: {‘licensePlates’: ‘$licensePlates’},’uniqueIds’: {‘$addToSet’: ‘$_id’},’count’ : {‘$sum’: 1}}}, {‘$match’: {‘count’: {‘$gt’: 1}}})


Exceeded memory limit for $group, but didn’t allow external sort. Pass allowDiskUse:true to opt in

原因是聚合的结果必须要限制在16M以内操作,(mongodb支持的最大影响信息的大小),否则必须放在磁盘中做缓存( allowDiskUse=True


修改为:

db.carMongoDTO.aggregate([{‘$group’:{‘_id’: {‘licensePlates’: ‘$licensePlates’},’uniqueIds’: {‘$addToSet’: ‘$_id’},’count’ : {‘$sum’: 1}}},{‘$match’: {‘count’: {‘$gt’: 1}}},{ “$limit” : 10}],{ allowDiskUse: true })



    原文作者:haoge0205
    原文地址: http://blog.itpub.net/28939273/viewspace-2660440/
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞