sort operation used more than the maximum 33554432 bytes of RAM. Add an index,or specify a smaller

生产环境mongodb 报错,
sort operation used more than the maximum 33554432 bytes of RAM. Add an index,or specify a smaller limit

mongodb 版本 3.2.6,下面是官方文档的描述

Sort Operations
If MongoDB cannot use an index to get documents in the requested sort order, the combined size of all documents in the sort operation, plus a small overhead, must be less than 32 megabytes.

解决方法
1、创建索引

--不阻塞创建索引
db.xxxxx.createIndex({"name":1,"sex":1},{"background":1})

2、增加sort memory

--查询当前值
db.runCommand({ getParameter : 1, "internalQueryExecMaxBlockingSortBytes" : 1 } )

--设置新值
db.adminCommand({setParameter:1, internalQueryExecMaxBlockingSortBytes:67108864})
posted @ 2018-02-12 17:40  peiybpeiyb  阅读(1364)  评论(0编辑  收藏  举报