I read that MongoDB has a limit of 4MB per document. I was not mistaken?

Asked bymilka cupac

Especially it is not clear if it is recommended to de-normalize the data - for example, store comments on the comment ...

comment:{Id:..., Text: ..., comments: []}

This is because you are resting on the limit and the pipe ...

Answers

agordhandas
In version 2.2, the size of one document is increased to 16M. Although, as many said at the top, GridFS will allow you to store files of any size. Even those that exceed the size of a single physical computer in a cluster.
carl webb
To get around the limitation, there is a GridFS, it seems :)
zanny
Mongo has another more interesting limitation www.mongodb.org/display/DOCS/Using+a+Large+Number+of+Collections

It bothers me more than 4mb on the record
Replies:
1) For text data - 4MB is a lot, all binary data will go to the GridFS
2) In version 1.7 it will be possible to customize
3) If you still go beyond 4MB, it is decided by changing the database structure - for the given example, we make the collection of comments “flat” with links. For more information on how to work with tree data in Mongo, see www.mongodb.org/display/DOCS/Trees+in+MongoDB - judith ivester
I apologize, it’s not wrong there - jessica wardzala
& gt; it bothers me more than 4mb per record
I understand that every day you have to work with databases with 24 thousand tables in each. Right? - gareth murphy
is incorrect.
I just do not want to change the paravoz to the shine of light;) - leah rose
manuel
This is configurable.
egliuka123
I think the problem is somewhat contrived, because the commentary to the comment can be stored flat with the foreign key. For data over 4mb there is a GridFS.
stuti
Same how many comments to write for 4 MB. On another 32 bit machines, the total base is limited to 2 GB, once started.
GridFS is still for binaries, I don’t think this is the best solution.
In extreme cases, you can specify in the application the maximum amount of comments stored in one document and, when reached, open a new one with a DBRef (foreign key) to the main one.
Replies:
In my opinion, the application logic will be easier if you store either the comments themselves or the link to the grid, where these comments are stored in a serialized form. Although it all depends on the task, if you need a search by comments, then yes, if you don’t write your search, then either continue the current document or store comments in a “normalized” form in a separate collection - klever
In the version with a separate collection for each post request second request for comments.
In the variant with continuation, we need a) to check every time the maximum is reached, b) the second request when it reaches, c) we lose the atomic addition of the comment, because you will need to first request the post again, check the limit and then add. This step can be optimized if you immediately add the ObjectID of a post or document to the form with a continuation of comments, and we can also add them atomically.
In general, I do not see a problem in 4 MB, moreover, if I roughly calculate that in the comments in Russian in Unicode and limit them to 1000 characters, this is 2 kb per comment, and 2000 comments in a post. IMHO in such situations it is better to spread them for the convenience of the reader in the first place. - lauren becker
thedap
1) For text data - 4MB is a lot, all binary data will go to GridFS
2) In version 1.7 it will be possible to customize
3) If you still go beyond 4MB, it is decided by changing the database structure - for the given example, we make the collection of comments “flat” with links. For more on options for working with tree data in Mongo, see www.mongodb.org/display/DOCS/Trees+in+MongoDB vansickle, Today at 23:07
What would you improve or change in the Habrahabr interface? :: Multilingual transliteration for PHP? :: How to teach Google to send the user not to the main page of the blog, but to a specific post? :: How to make a public account balance counter, for example, Yandex.Money :: How to show a page with a frameset, even if the user opened the page of an individual frame (part of the frameset)?
Leave Repply forI read that MongoDB has a limit of 4MB per document. I was not mistaken?
Useful Links