Exceeded memory limit for $group

发布于 2022-09-03 13:47:13 字数 473 浏览 12 评论 0

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧故 2022-09-10 13:47:13

$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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文