首页 > MongoDB单文档大小限制是16M吗?这里包括嵌入的子文档吗?

MongoDB单文档大小限制是16M吗?这里包括嵌入的子文档吗?

从官方文档http://cn.docs.mongodb.org/manual/ref...:
BSON Object Size
The maximum BSON object size is 16 megabytes.

这是指单文档限制16M吗?包括嵌入的子文档吗?


是的,包括嵌入的(embedded)子文档在内。

这个限制是为了避免单个文档过大,完整读取时对内存或者网络带宽占用过高。根据目前MongoDB主开发人员的意思,他们不打算放开这个限制,但会随着计算资源相对成本的降低(内存更便宜,网络更快)而适度调高。

官方解释:

MongoDB limits the data size of individual BSON objects/documents. At the time of this writing the limit is 16MB.

This limit is designed as a sanity-check; it is not a technical limit on document sizes. The thinking is that if documents are larger than this size, it is likely the schema is not ideal. Further it allows drivers to make some assumptions on the max size of documents.

The concept is that the maximum document size is a limit that ensures each document does not require an excessive amount of RAM from the machine, or require too much network bandwidth to fetch. For example, fetching a full 100MB document would take over 1 second to fetch over a gigabit ethernet connection. In this situation one would be limited to 1 request per second.

Over time, as computers grow in capacity, the limit will be adjusted upward.
【热门文章】
【热门文章】