MongoDB : Sort exceeded memory limit of 104857600 bytes

摘要: Performs a large sort operation (Aggregation) in a collection, and hits the following error message :

Performs a large sort operation (Aggregation) in a collection, and hits the following error message :

MongoDB Console
> db.bigdata.aggregate(
	{$group : {_id : "$range", total : { $sum : 1 }}},
	{$sort : {total : -1}}
);
#...
 aggregate failed
    at Error (<anonymous>)
    at doassert (src/mongo/shell/assert.js:11:14)
    #...
    Error: command failed: {
        "errmsg" : "exception: Sort exceeded memory limit of 104857600 bytes, 
		  but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in.",
        "code" : 16819,
        "ok" : 0

P.S Tested with MongoDB 3.0.6

Solution

Changed in version 2.6 – Read this Memory Restrictions
In MongoDB, the in-memory sorting have a limit of 100M, to perform a large sort, you need enable allowDiskUse option to write data to a temporary files for sorting.

To fix it, enable the allowDiskUse option in your query :

db.bigdata.aggregate(
	{$group : {_id : "$range", total : { $sum : 1 }}},
	{$sort : {total : -1}}
],
	{allowDiskUse: true}
);

References

  1. Perform Large Sort Operation with External Sort
  2. Aggregation Pipeline Limits
  3. MongoDB – Aggregate and Group example

上一篇: Spring 4 MVC Ajax Hello World Example
下一篇: Java How to split a string
 评论 ( What Do You Think )
名称
邮箱
网址
评论
验证
   
 

 


  • 微信公众号

  • 我的微信

站点声明:

1、一号门博客CMS,由Python, MySQL, Nginx, Wsgi 强力驱动

2、部分文章或者资源来源于互联网, 有时候很难判断是否侵权, 若有侵权, 请联系邮箱:summer@yihaomen.com, 同时欢迎大家注册用户,主动发布无版权争议的 文章/资源.

3、鄂ICP备14001754号-3, 鄂公网安备 42280202422812号