I wasn't able to find any information on the max length for a string data type in MongoDB on the main mongodb.org site. I'm coming from a relational database background and there are usually max lengths. Thank you!
我无法在主mongodb.org网站上找到有关MongoDB中字符串数据类型的最大长度的任何信息。我来自关系数据库背景,通常有最大长度。谢谢!
2 个解决方案
#1
30
This other question should answer your question:
这个问题应该回答你的问题:
Documents larger than 4MB (when converted to BSON) cannot be saved to the database. This is a somewhat arbitrary limit (and may be raised in the future); it is mostly to prevent bad schema design and ensure consistent performance.
大于4MB的文档(转换为BSON时)无法保存到数据库中。这是一个有点任意的限制(将来可能会提出);它主要是为了防止错误的架构设计并确保一致的性能。
Note that in the picked answer for that question the commenter mentions that it could be as large as 8mb or 16mb now.
请注意,在该问题的挑选答案中,评论者提到它现在可能大到8mb或16mb。
So to answer your question, it's not necessarily that a single string can only be a certain length, but rather that the whole document must be under 16MB.
因此,要回答您的问题,单个字符串不一定只能是一定长度,而是整个文档必须小于16MB。
#2
1
See this:
看到这个:
The maximum BSON document size is 16 megabytes. The maximum document size helps ensure that a single document cannot use excessive amount of RAM or, during transmission, excessive amount of bandwidth. To store documents larger than the maximum size, MongoDB provides the GridFS API.
最大BSON文档大小为16兆字节。最大文档大小有助于确保单个文档不会使用过多的RAM,或者在传输过程中使用过多的带宽。为了存储大于最大大小的文档,MongoDB提供了GridFS API。
#1
30
This other question should answer your question:
这个问题应该回答你的问题:
Documents larger than 4MB (when converted to BSON) cannot be saved to the database. This is a somewhat arbitrary limit (and may be raised in the future); it is mostly to prevent bad schema design and ensure consistent performance.
大于4MB的文档(转换为BSON时)无法保存到数据库中。这是一个有点任意的限制(将来可能会提出);它主要是为了防止错误的架构设计并确保一致的性能。
Note that in the picked answer for that question the commenter mentions that it could be as large as 8mb or 16mb now.
请注意,在该问题的挑选答案中,评论者提到它现在可能大到8mb或16mb。
So to answer your question, it's not necessarily that a single string can only be a certain length, but rather that the whole document must be under 16MB.
因此,要回答您的问题,单个字符串不一定只能是一定长度,而是整个文档必须小于16MB。
#2
1
See this:
看到这个:
The maximum BSON document size is 16 megabytes. The maximum document size helps ensure that a single document cannot use excessive amount of RAM or, during transmission, excessive amount of bandwidth. To store documents larger than the maximum size, MongoDB provides the GridFS API.
最大BSON文档大小为16兆字节。最大文档大小有助于确保单个文档不会使用过多的RAM,或者在传输过程中使用过多的带宽。为了存储大于最大大小的文档,MongoDB提供了GridFS API。