Skip to content

Commit 8d621ab

Browse files
committed
DOCS-685 power of 2 in faq padding
1 parent 79b0c5d commit 8d621ab

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

source/core/write-operations.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,17 +355,17 @@ contiguous space to fit the larger document. Since the move will
355355
require an update of all the indexes for the document, if the
356356
collection has many indexes, the move will impact write performance.
357357

358-
To minimize document movements, MongoDB employs padding. MongoDB adaptively
359-
learns if documents in a collection tend to grow, and if they do, adds
360-
a :stats:`paddingFactor` so that the document has room to grow on
361-
subsequent writes. The :stats:`paddingFactor` indicates the padding for
362-
new inserts and moves.
358+
To minimize document movements, MongoDB employs padding. MongoDB
359+
adaptively learns if documents in a collection tend to grow, and if
360+
they do, adds a :stats:`paddingFactor` so that the documents have room
361+
to grow on subsequent writes. The :stats:`paddingFactor` indicates the
362+
padding for new inserts and moves.
363363

364364
.. versionadded:: 2.2
365365
You can use the :dbcommand:`collMod` command with the
366-
``usePowerOf2Sizes`` flag so that MongoDB allocates document space
367-
in sizes that are powers of 2. As with all padding, using powers of
368-
2 minimizes, but does not eliminate, document movements.
366+
:collflag:`usePowerOf2Sizes` flag so that MongoDB allocates document
367+
space in sizes that are powers of 2. As with all padding, using
368+
powers of 2 minimizes, but does not eliminate, document movements.
369369

370370
To check the current :stats:`paddingFactor` on a collection, you can
371371
run the :dbcommand:`db.collection.stats()` command in the

source/faq/developers.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ information on indexes.
660660
.. Commenting out.. If your small documents are approximately the page
661661
cache unit size, there is no benefit for ram cache efficiency, although
662662
embedding will provide some benefit regarding random disk i/o.
663-
=======
663+
664664
.. _faq-developers-manual-padding:
665665

666666
Can I manually pad documents to prevent moves during updates?
@@ -671,7 +671,14 @@ size. To *minimize* document movements, MongoDB uses
671671
:ref:`padding <write-operations-padding-factor>`.
672672

673673
You should not have to pad manually because MongoDB handles
674-
:ref:`padding automatically <write-operations-padding-factor>`.
674+
:ref:`padding automatically <write-operations-padding-factor>`. MongoDB
675+
adaptively learns if documents in a collection tend to grow, and if
676+
they do, adds a :stats:`paddingFactor` so that documents have room to
677+
grow on subsequent writes. You can change the default
678+
:stats:`paddingFactor` calculation by using the the
679+
:dbcommand:`collMod` command with the :collflag:`usePowerOf2Sizes`
680+
flag. The :collflag:`usePowerOf2Sizes` flag ensures that MongoDB
681+
allocates document space in sizes that are powers of 2.
675682

676683
However, in those exceptions where you must pad manually, you can use
677684
the strategy of first adding a temporary field to a document and then

0 commit comments

Comments
 (0)