How to mitigate 16MB per document limit imposed by MongoDB?
If you are building a web app, documents will start growing. Especially content based websites. How should we handle this problem? What should I do when my documents start growing and are about to hit this limit?
Well, if you really get 16MB at your document in MongoDB, probably something goes wrong.
When you modeling your document(model) for MongoDB, you have some features to prevent store much more redundant information thats necessary.
I follow the rule: If you've a subdocument set that you don't have control over it, like comments in a post, is much better just have an array of references for another collection. But if you have control over your subdocument, like metadata, you can just use this subdocument direct on your document not using a reference.
But, if follow this rule and you still get 16MB at your document, well, try thinking about a SQL like database and normalize your data.
Marcos Bérgamo
Backend Developer
Well, if you really get 16MB at your document in MongoDB, probably something goes wrong.
When you modeling your document(model) for MongoDB, you have some features to prevent store much more redundant information thats necessary.
I follow the rule: If you've a subdocument set that you don't have control over it, like comments in a post, is much better just have an array of references for another collection. But if you have control over your subdocument, like metadata, you can just use this subdocument direct on your document not using a reference.
But, if follow this rule and you still get 16MB at your document, well, try thinking about a SQL like database and normalize your data.