Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 478
Goalie Avatar asked May 31 '12 05:05

Goalie


People also ask

What is the max length of string in MongoDB?

MongoDB connector limits text field to 255 characters.

How do I find the length of a string in MongoDB?

As for the logical condition, there are String Aggregation Operators that you can use $strLenCP operator to check the length of the string. If the length is $gt a specified value, then this is a true match and the document is "kept".

What is the maximum size supported by MongoDB for the document?

As you know, MongoDB stores data in a document. The limit for one document is 16Mb. You can also use GridFS to store large files that can exceed 16Mb.


1 Answers

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.

Note that in the picked answer for that question the commenter mentions that it could be as large as 8mb or 16mb now.

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.

like image 94
Ryan Bigg Avatar answered Oct 08 '22 22:10

Ryan Bigg