Is MongoDB’s single document size limit 16M? Does this include embedded subdocuments?

  mongodb, question

From official documentshttp://cn.docs.mongodb.org/manual/ref …
BSON Object Size
The maximum BSON object size is 16 megabytes.

Does this mean a single document limit of 16M? Include embedded subdocuments?

Yes, including embedded subdocuments.

This restriction is to prevent a single document from being too large and occupying too much memory or network bandwidth during full reading. According to the current meaning of MongoDB’s main developers, they do not intend to release this restriction, but will increase it moderately as the relative cost of computing resources decreases (cheaper memory and faster network).

Official explanation:

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.