Skip to content

DOCS-7143: Update collStats page with examples #2561

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
40 changes: 40 additions & 0 deletions source/includes/apiargs-dbcommand-collStats-field.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
arg_name: field
description: |
The name of the target collection.

If the collection does not exist, :dbcommand:`collStats` returns
an error message.
interface: dbcommand
name: collStats
operation: collStats
optional: false
position: 1
type: string
---
arg_name: field
description: |
The scale used in the output to display the sizes of items. By default,
output displays sizes in bytes. To display kilobytes rather than bytes,
specify a ``scale`` value of ``1024``.

The scale factor rounds values to whole numbers.
interface: dbcommand
name: scale
operation: collStats
optional: true
position: 2
type: int
---
arg_name: field
description: |
When ``true``, :dbcommand:`collStats` increases reporting for the
:ref:`storage-mmapv1`.

Defaults to false.
interface: dbcommand
name: verbose
operation: collStats
optional: true
position: 3
type: boolean
...
2 changes: 2 additions & 0 deletions source/includes/fact-dbcommand.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
To run |command|, use the :method:`db.runCommand( { \<command\> } )
<db.runCommand()>` method.
39 changes: 23 additions & 16 deletions source/reference/command/collStats.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ Definition
.. dbcommand:: collStats

The :dbcommand:`collStats` command returns a variety of storage statistics
for a given collection. Use the following syntax:
for a given collection.

.. |command| replace:: ``collStats``

.. code-block:: javascript
.. include:: /includes/fact-dbcommand.rst

The :dbcommand:`collStats` command has the following syntax:

{ collStats: "collection" , scale : 1024, verbose: true }
.. code-block:: javascript

Specify the ``collection`` you want statistics for, and use the
``scale`` argument to scale the output: a value of ``1024`` renders
the results in kilobytes.
{
collStats: <string>,
scale: <int>,
verbose: <boolean>
}

.. note::
The command takes the following fields:

The scale factor rounds values to whole numbers.
.. include:: /includes/apiargs/dbcommand-collStats-field.rst

Behavior
--------

Verbosity and MMAPv1
~~~~~~~~~~~~~~~~~~~~

The ``verbose: true`` option increases reporting for the MMAPv1 storage
engine.

Unexpected Shutdown and Count
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand All @@ -48,8 +48,15 @@ may off by up to 1000 documents as reported by :dbcommand:`collStats`,
:dbcommand:`dbStats`, :dbcommand:`count`. Run :dbcommand:`validate` on
the collection to restore the correct statistics for the collection.

Example Output
--------------
Example
-------

The following operation runs the :dbcommand:`collStats` command on the
``restaurant`` collection, specifying a scale of ``1024`` bytes:

.. code-block:: javascript

db.runCommand( { collStats : "restaurant", scale: 1024 } )

The following document provides a representation of the
:dbcommand:`collStats` output. Depending on the configuration of your
Expand Down