Resulting document after update is larger than 16777216

博客讨论了在更新文档导致数据量超过16MB限制的问题,提出了两种解决办法:优化MongoDB代码逻辑以避免大对象存储,或者直接修改MongoDB源码并自建版本。文章还提到了MongoDB对于大对象的内部处理限制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

依赖包是

 

问题原因:

更新文档后data的数据量太大了,超过了16M。

解决办法:

1、优化自己的mongo代码逻辑,取消文档中的集合存储已文档的方式存储

2、修改mongo的源码,改变源代码并从源代码构建自己的mongo版本。

/* Note the limit here is rather arbitrary and is simply a standard. generally the code works
   with any object that fits in ram.
   Also note that the server has some basic checks to enforce this limit but those checks are not exhaustive
   for example need to check for size too big after
     update $push (append) operation
     various db.eval() type operations
*/
const int BSONObjMaxUserSize = 16 * 1024 * 1024;

/*
   Sometimes we need objects slightly larger - an object in the replication local.oplog
   is slightly larger than a user object for example.
*/
const int BSONObjMaxInternalSize = BSONObjMaxUserSize + ( 16 * 1024 );

const int BufferMaxSize = 64 * 1024 * 1024;

参考mongo/builder.h at 4211c6a8de32fa774b1c28fb82a96f965fd550b7 · mongodb/mongo · GitHub

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值