zoukankan      html  css  js  c++  java
  • Query failed with error code 96 and error message 'Executor error during find command: OperationFailed: Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smal

    首先问题很明确,当我对一个没有建索引的字段做find,然后做sort的时候,可能触发sort的size的32MB限制,而mongodb的sort操作是把数据拿到内存中再进行排序的,为了节约内存,默认给sort操作限制了最大内存为32Mb,当数据量越来越大直到超过32Mb的时候就自然抛出异常了!

    解决方案有两种(建议添加索引):

    一、为该字段添加索引

    db.CollectionName(表名).createIndexes({"title":1})  //title为字段名,1为正序,-1为倒序

    二、修改默认配置,把sort时可以用的内存设置大点

    db.adminCommand({setParameter:1, internalQueryExecMaxBlockingSortBytes:335544320}) //该命令是扩大sort限制为320MB

  • 相关阅读:
    SQL结构化查询语言
    数据库主外键
    SQL数据库数据类型详解
    注释和特殊符号
    文本装饰
    列表样式
    网页背景
    SQL数据库数据类型详解
    数据库主外键
    Update 语句
  • 原文地址:https://www.cnblogs.com/drunkPullBreeze/p/10998766.html
Copyright © 2011-2022 走看看