Mongo的排序内存 默认32M,超过后,查询报错【Sort operation used more than the maximum 33554432 bytes of RAM】
报错问题
Query failed with error code 96 and error message 'Executor error during find command :: caused by :: Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit.
思路
- 提示说添加索引,或者增加内存参数
 - 按照提示,增加过索引,因为我排序字段有两个,刚开始建立的独立索引时,无效。
 - 建立的是联合索引,确实可以解决内存问题了,但是查询时mongo选择了这个索引,没有选择更优的索引字段,导致查询变慢了
 - 遂将索引删除后,走了添加排序内存的方式 将原先的32M改为了100M 查询后,不报错且正常
db.adminCommand({ setParameter: 1, internalQueryExecMaxBlockingSortBytes: 104857600 }); 
    惜秦皇汉武,略输文采;唐宗宋祖,稍逊风骚。
一代天骄,成吉思汗,只识弯弓射大雕。
俱往矣,数风流人物,还看今朝
                    
                
                
            
        
浙公网安备 33010602011771号