Question

Say that I have a document looking like:

{
    "_id" : "1234",
    "foo" : {
        "bar1" : 2
    }
}

Does adding a "bar2" field in "foo" cause document growth, which means that it has to be moved on the disk, etc?

Thanks

Was it helpful?

Solution

From the MongoDB documentation:

Update operations can increase the size of the document. If a document outgrows its current allocated record space, MongoDB must allocate a new space and move the document to this new location.

To reduce the number of moves, MongoDB includes a small amount of extra space, or padding, when allocating the record space. This padding reduces the likelihood that a slight increase in document size will cause the document to exceed its allocated record size.

You can read more about it here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top