Exceeded memory limit for $group, but didn’t allow external sort
因为Mongodb的聚合操作管道的输出结果不能超过16M,超过16M会出现错误。
- Mongodb
allowDiskUse: true
1 | db.stocks.aggregate( |
- Mongoose
allowDiskUse(true)
1 | await stocks.aggregate([{ $match:{price:1}}, {$group: {_id:{date:"$date"}, sum:{$sum:"$price"}}}]).allowDiskUse(true); |