ITPub博客

首页 > 数据库 > NoSQL > Exceeded memory limit for $group, but didn't allow external sort. Pass allowDisk

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

原创 NoSQL 作者:haoge0205 时间:2019-10-17 20:06:45 0 删除 编辑

原语句:

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 })



来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28939273/viewspace-2660440/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-11-28

  • 博文量
    300
  • 访问量
    1893493