Manually padding a document
Without getting too much into the internals of the storage, MongoDB uses memory mapped files, which means that the data is stored in files exactly as how it would be in memory and it would use the low level OS services to map these pages to memory. The documents are stored in continuous locations in mongo data files and problem arises when the document grows and no longer fits in the space. In such scenarios, mongo rewrites the document towards the end of the collection with the updated data and clearing up the space where it was originally placed (note that this space is not released to OS as free space).
This is not a big problem for applications that don't expect the documents to grow in size. However, this is a big ...
Get MongoDB Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.