Skip to content

DOCS-4061: Capped collection documentation #2031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions source/core/capped-collections.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ internal overhead.

db.createCollection( "log", { capped: true, size: 100000 } )

If the ``size`` field is less than or equal to 4096, then the collection will
have a cap of 4096 bytes. Otherwise, MongoDB will raise the provided size to
make it an integer multiple of 256.

Additionally, you may also specify a maximum number of documents for the
collection using the ``max`` field as in the following document:

Expand Down
51 changes: 23 additions & 28 deletions source/reference/command/collStats.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ Definition
The scale factor rounds values to whole numbers. This can
produce unpredictable and unexpected results in some situations.

If :dbcommand:`collStats` operates on a :term:`capped collection`, then the
following fields will also be present:

.. code-block:: javascript

> db.users.stats()
{
...
"capped" : true,
"max" : NumberLong("9223372036854775807"),
"ok" : 1
}

Output
------

Expand Down Expand Up @@ -142,7 +155,7 @@ Output
Reports the flags on this collection set by the user. In version
2.2 the only user flag is :collflag:`usePowerOf2Sizes`.
If :collflag:`usePowerOf2Sizes` is enabled, :data:`~collStats.userFlags` will
be set to ``1``, otherwise :data:`~collStats.userFlags` will be ``0``.
be set to ``1``, otherwise it will be ``0``.

See the :dbcommand:`collMod` command for more information on setting user
flags and :collflag:`usePowerOf2Sizes`.
Expand All @@ -157,30 +170,12 @@ Output
This field specifies the key and size of every existing index on
the collection. The ``scale`` argument affects this value.

Example
-------

The following is an example of :method:`db.collection.stats()` and
:dbcommand:`collStats` output:

.. code-block:: javascript

{
"ns" : "<database>.<collection>",
"count" : <number>,
"size" : <number>,
"avgObjSize" : <number>,
"storageSize" : <number>,
"numExtents" : <number>,
"nindexes" : <number>,
"lastExtentSize" : <number>,
"paddingFactor" : <number>,
"systemFlags" : <bit>,
"userFlags" : <bit>,
"totalIndexSize" : <number>,
"indexSizes" : {
"_id_" : <number>,
"a_1" : <number>
},
"ok" : 1
}
.. data:: collStats.capped

This field will be "true" if the collection is
:term:`capped <capped collection>`.

.. data:: collStats.max

Shows the maximum number of documents that may be present in a
:term:`capped collection`.