Considering Document Growth

When you update a document, you need to consider what effect the new data will have on document growth. MongoDB provides some padding in documents to allow for typical growth during an update operation. However, if an update causes a document to grow until it exceeds the allocated space on disk, MongoDB has to relocate that document to a new location on the disk, incurring a performance hit on the system. Also, frequent document relocation can lead to disk fragmentation issues—for example, if a document contains an array and you add enough elements to the array.

One way to mitigate document growth is to utilize normalized objects for the properties that may grow frequently. For example, instead of using an array to store items in a Cart object, you could create a collection for CartItems and store new items that get placed in the Cart object as new documents in the CartItems collection and reference the user’s Cart items within them.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.171.46