与 Ruby 一起使用的 MongoDB 中字符串数据类型的最大长度是多少?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10827812/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 05:09:47  来源:igfitidea点击:

What is the length maximum for a string data type in MongoDB used with Ruby?

rubymongodbmongoid

提问by Goalie

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 中字符串数据类型最大长度的任何信息。我来自关系数据库背景,通常有最大长度。谢谢!

回答by Ryan Bigg

This other questionshould 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 documentmust be under 16MB.

所以回答你的问题,不一定是单个字符串只能有一定的长度,而是整个文档必须在16MB以下。

回答by Guido Mocha

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

回答by Hyman lee

Follow here

按照这里

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. See mongofiles and the documentation for your driver for more information about GridFS.

最大 BSON 文档大小为 16 兆字节。

最大文档大小有助于确保单个文档不会使用过多的 RAM,或者在传输过程中不会使用过多的带宽。为了存储大于最大大小的文档,MongoDB 提供了 GridFS API。有关 GridFS 的更多信息,请参阅 mongofiles 和驱动程序的文档。