项目场景:
在SpringBoot项目查询MongoDB表数据
问题描述
出现了"Sort operation used more than the maximum 33554432 bytes of RAM"异常。
原因分析:
由于排序的时候加载到内存的数据太多了,排序操作所使用的内存超过了33554432 字节(32M)。
解决方案:
1.在mongoDB表增加索引:
db.表名.createIndex({列名:1});
比如:
db.student.createIndex({studentName:1});
查询生成的索引:
db.supply_demand_balance_data.getIndexes();
2.修改默认配置,增加内存空间分配:
db.adminCommand({setParameter:1, internalQueryExecMaxBlockingSortBytes:335544320})
╭◜◝ ͡ ◜◝╮
( ˃̶͈◡˂ ̶͈ )感觉有用的话,欢迎点赞评论呀!
╰◟◞ ͜ ◟◞╯