mongodb - Exceeded memory limit for $group
PHPz
PHPz 2017-05-02 09:21:28
0
1
1024

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

query_data_total = coll.aggregate([
    {"$match": {"order_date": {"$gte": start_date, "$lte": end_date},
                }},
    {"$group": {"_id": "$order_date",
                "gmv": {"$sum": "$price"}, "ticket_num": {"$sum": 1}, "order_num": {"$addToSet": "$order_id"}}
     }
])

使用aggregate聚合查询  但查询几天的数据的时候没有问题  当天数多了之后就报错 用的是pymongo
PHPz
PHPz

学习是最好的投资!

全部回复(1)
某草草

$group有内存限制你的数据量超过了限制而且没有指定允许使用额外的磁盘进行操作于是就报错了
The $group stage has a limit of 100 megabytes of RAM. By default, if the stage exceeds this limit, $group will produce an error. However, to allow for the handling of large datasets, set the allowDiskUse option to true to enable $group operations to write to temporary files.See db.collection.aggregate() method and the aggregate command for details.

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!