最近在获取mongodb某个集合的数据过程中,在进行排序的过程中报错,具体报错信息如下:

  

Error: error: {
"ok" : ,
"errmsg" : "Executor error during find command: OperationFailed: Sort op
eration used more than the maximum bytes of RAM. Add an index, or speci
fy a smaller limit.",
"code" : ,
"codeName" : "OperationFailed"
}

  知道这是排序的时候报的错,因为 mongo 的 sort 操作是在内存中操作的,必然会占据内存,同时mongo 内的一个机制限制排序时最大内存为 32M,当排序的数据量超过 32M,就会报上面的这个错,

  解决办法就像上面提示的意思,一是加大 mongo 的排序内存,这个一般是运维来管,也有弊端,就是数据量如果再大,还要往上加。另一个办法就是加索引。

  

 创建索引

  db.你的collection.createIndex({"你的字段": -1}),此处 -1 代表倒序,1 代表正序;

  比如对trsdata集合的IR_URLTIME字段建立索引:db.trsdata.createIndex({"IR_URLTIME": -1})

  查询索引: db.trsdata.getIndexes()

  这样建立索引后就可以进行排序了。

MongoDB Sort op eration used more than the maximum 33554432 bytes of RAM. Add an index, or speci fy a smaller limit.的更多相关文章

  1. Mongodb: Sort operation used more than the maximum 33554432 bytes of RAM

    上线许久的产品突然爆出了一个Mongodb 查询的BUG,错误如下: "exception":"org.springframework.data.mongodb.Unca ...

  2. Overflow sort stage buffered data usage of 33554495 bytes exceeds internal limit of 33554432 bytes

    MongoDB执行错误: Overflow sort stage buffered data usage of 33554495 bytes exceeds internal limit of 335 ...

  3. mongodb sort limit和skip用法

    > db.mediaCollection.find().skip().toArray() [ { "_id" : ObjectId("5353463193efef0 ...

  4. mongodb sort

    sort() 方法 要在 MongoDB 中的文档进行排序,需要使用sort()方法. sort() 方法接受一个文档,其中包含的字段列表连同他们的排序顺序.要指定排序顺序1和-1. 1用于升序排列, ...

  5. mongodb Sort排序能够支持的最大内存限制为32M Plan executor error during find: FAILURE

    1.一个比较老的游戏服维护,关服维护后启动时报错 2.看到关于mongodb的报错,于是去查一下mongodb的日志 Plan executor error during find: FAILURE, ...

  6. MongoDB排序异常

    com.mongodb.MongoQueryException: Query failed with error code 96 and error message 'Executor error d ...

  7. Mongodb——文档数据库

    mongodb是一个文档数据库. mongo操作 多个修改操作,但每个修改携带的数据包较小,可操作考虑批量操作.bulkWrite()改善性能. MongoCollection是线程安全的. db.c ...

  8. mongodb报错一例

    开发程序报错信息: Caused by: com.mongodb.MongoException: Executor error: OperationFailed: Sort operation use ...

  9. 一个MongoDB索引走偏的案例及探究分析

    接业务需求,有一个MongoDB的简单查询,太耗时了,执行了 70S 左右,严重影响用户的体验.. 查询代码主要如下: db.duoduologmodel.find({"Tags.SN&qu ...

随机推荐

  1. [BZOJ4565][HAOI2016]字符合并(区间状压DP)

    https://blog.csdn.net/xyz32768/article/details/81591955 首先区间DP和状压DP是比较明显的,设f[L][R][S]为将[L,R]这一段独立操作最 ...

  2. BZOJ 2118 墨墨的等式(最短路)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=2118 [题目大意] 求a1x1+a2y2+…+anxn=B在B的取值范围,有多少B可以 ...

  3. Azure ServiceBus的消息中带有@strin3http//schemas.microsoft.com/2003/10/Serialization/�

    今天碰到一个很讨厌的问题,使用nodejs 接收Azure service bus队列消息的时候,出现了:@strin3http//schemas.microsoft.com/2003/10/Seri ...

  4. [COGS2639]偏序++

    [COGS2639]偏序++ 题目大意: \(n(n\le40000)\)个\(k(k\le7)\)元组,求\(k\)维偏序. 思路: 分块后用bitset维护. 时间复杂度\(\mathcal O( ...

  5. hihocoder #1015 KMP

    #include<stdio.h> #include<iostream> #include<math.h> #include<string.h> usi ...

  6. Python知识(6)--numpy做矩阵运算

    矩阵运算 论numpy中matrix 和 array的区别:http://blog.csdn.net/vincentlipan/article/details/20717163 matrix 和 ar ...

  7. Git_操作标签

    如果标签打错了,也可以删除: $ git tag -d v0.1 Deleted tag 'v0.1' (was e078af9) 因为创建的标签都只存储在本地,不会自动推送到远程.所以,打错的标签可 ...

  8. 斑马Zebra驱动下载

    Zebra GT800 点击进入下载页-> 自动安装包[WINXP/WIN7/WIN8]点击进入下载页-> 添加打印机向导[WINXP/WIN7/WIN8]   热门下载 · Zebra ...

  9. C#程序集系列03,引用多个module

    我们经常在项目中引用程序集.通常情况下,一个程序集包含一个module,但一个程序集也可以包含多个module.本篇就来体验:在一个可以被编译成.exe可执行文件的.cs文件中引用多个module. ...

  10. java string常见操作(二)