您现在的位置是:亿华云 > IT科技
MongoDB排序时内存大小限制与创建索引的注意事项详解
亿华云2025-10-08 19:11:30【IT科技】4人已围观
简介线上服务的MongoDB中有一个很大的表,我查询时使用了sort()根据某个字段进行排序,结果报了下面这个错误:[Error] Executor error during find command :
线上服务的序时限制项详MongoDB中有一个很大的表,我查询时使用了sort()根据某个字段进行排序,内存结果报了下面这个错误:
[Error] 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.
这是个非常常见的MongoDB报错了。因为MongoDB处理排序时,创建如果排序的企商汇索引字段没有建立索引,会把全表都丢到内存中处理。意事
If MongoDB cannot use an index or 序时限制项详indexes to obtain the sort order, MongoDB must perform a blocking sort operation on the data. A blocking sort indicates that MongoDB must consume and process all input documents to the sort before returning results.
而内存的大小并不是无限使用的,MongoDB的内存默认设置是32MB。源码库一旦数据量超过32MB,大小的注则会报错。创建
参数internalQueryExecMaxBlockingSortBytes
32MB这个限制是索引在参数internalQueryExecMaxBlockingSortBytes中控制。你可以在MongoDB的意事客户端上直接查看这个参数的值,执行以下语句:
?序时限制项详网站模板很赞哦!(2)