I want to enforce a maximum document size that is lower than the system actually supports. Doing so on an insert is reasonable -- I can just check before insertion. Doing so on an update is less clear. I don't want to have to read back the entire document to check that the update didn't balloon it over the size. What should I do? Can I lower the max document size so that it throws an exception upon update?
Asked
Active
Viewed 394 times
2 Answers
0
I dont believe there is a way to custom set your max doc size in mongo. You dont have to worry about that too much. currently the max document size is 16 MB.. Its a lotttt of text.
Can you specify a use case why do you think that your doc size may exceed the default limit. if you found the case, its better to restructure your data model. thats the only way.

RameshVel
- 64,778
- 30
- 169
- 213
-
No, he wants to set his own limit, that is lower than system imposes. – Sergio Tulentsev Feb 17 '12 at 08:30
-
@SergioTulentsev yes thats what i said, OP's new doc size(lower than the default) is now the new max size, right :) – RameshVel Feb 17 '12 at 08:44
0
Actually, yes, you can lower the document size limit. This involves changing one constant in source code and recompiling mongo.
You better not run this recompiled server against old database. I don't know what'll happen if it finds a document larger than new size limit.

Sergio Tulentsev
- 226,338
- 43
- 373
- 367