Skip to content

DOCS-1474 moved database-statistics to dbStats #955

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
8 changes: 8 additions & 0 deletions bin/htaccess.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,14 @@ redirect-path: '/reference/current-op'
url-base: '/reference/method/db.currentOp'
type: 'redirect'
code: 301
outputs:
- 'after-v2.2'
- 'manual'
---
redirect-path: '/reference/database-statistics'
url-base: '/reference/command/dbStats'
type: 'redirect'
code: 301
outputs:
- 'after-v2.2'
- 'manual'
Expand Down
2 changes: 1 addition & 1 deletion source/administration/monitoring.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ of the replica set.
``dbStats``
```````````

The :doc:`dbStats data </reference/database-statistics>` is accessible
The :doc:`dbStats data </reference/command/dbStats>` is accessible
by way of the :dbcommand:`dbStats` command (:method:`db.stats()` from
the shell). This command returns a
document that contains data that reflects the amount of storage used
Expand Down
2 changes: 1 addition & 1 deletion source/faq/storage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ What tools can I use to investigate storage use in MongoDB?

The :method:`db.stats()` method in the :program:`mongo` shell,
returns the current state of the "active" database. The
:doc:`/reference/database-statistics` document describes
:doc:`dbStats command </reference/command/dbStats>` document describes
the fields in the :method:`db.stats()` output.

What is the working set?
Expand Down
2 changes: 1 addition & 1 deletion source/meta/reference.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Status, Monitoring, and Reporting Output
:maxdepth: 3

/reference/command/serverStatus
/reference/database-statistics
/reference/command/dbStats
/reference/command/connPoolStats
/reference/command/collStats
/reference/replica-status
Expand Down
2 changes: 1 addition & 1 deletion source/reference.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Status and Reporting
.. toctree::
:maxdepth: 1

reference/database-statistics
reference/command/dbStats
reference/command/collStats
reference/command/connPoolStats
reference/command/validate
Expand Down
136 changes: 120 additions & 16 deletions source/reference/command/dbStats.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ dbStats

.. default-domain:: mongodb

Definition
----------

.. dbcommand:: dbStats

The :dbcommand:`dbStats` command returns storage statistics for a
Expand All @@ -13,19 +16,120 @@ dbStats

{ dbStats: 1, scale: 1 }

The value of the argument (e.g. ``1`` above) to ``dbStats`` does
not affect the output of the command. The ``scale`` option allows
you to specify how to scale byte values. For example, a ``scale``
value of ``1024`` will display the results in kilobytes rather
than in bytes.

The time required to run the command depends on the total size of the database.
Because the command has to touch all data files, the command may take several
seconds to run.

In the :program:`mongo` shell, the :method:`db.stats()` function provides
a wrapper around this functionality. See the
":doc:`/reference/database-statistics`" document for an overview of
this output.

.. read-lock
The values of the options above do not affect the output of the
command. The ``scale`` option allows you to specify how to scale byte
values. For example, a ``scale`` value of ``1024`` will display the
results in kilobytes rather than in bytes:

.. code-block:: javascript

{ dbStats: 1, scale: 1024 }

.. note::

Because scaling rounds values to whole numbers, scaling may return
unlikely or unexpected results.

The time required to run the command depends on the total size of the
database. Because the command must touch all data files, the command
may take several seconds to run.

In the :program:`mongo` shell, the :method:`db.stats()` function
provides a wrapper around :dbcommand:`dbStats`.

Output
------

.. data:: dbStats.db

Contains the name of the database.

.. data:: dbStats.collections

Contains a count of the number of collections in that database.

.. data:: dbStats.objects

Contains a count of the number of objects (i.e. :term:`documents <document>`) in
the database across all collections.

.. data:: dbStats.avgObjSize

The average size of each document in bytes. This is the
:data:`~dbStats.dataSize` divided by the number of documents.

.. data:: dbStats.dataSize

The total size of the data held in this database including the
:term:`padding factor`. The ``scale`` argument affects this
value. The :data:`~dbStats.dataSize` will not decrease when :term:`documents
<document>` shrink, but will decrease when you remove documents.

.. sum of all records not counting deleted records

.. data:: dbStats.storageSize

The total amount of space allocated to collections in this database
for :term:`document` storage. The ``scale`` argument affects this
value. The :data:`~dbStats.storageSize` does not decrease as you remove or
shrink documents.

.. sum of all extents (no indexes or the $freelist)
.. include links to eventual documentation of storage management

.. data:: dbStats.numExtents

Contains a count of the number of extents in the database across
all collections.

.. data:: dbStats.indexes

Contains a count of the total number of indexes across all
collections in the database.

.. data:: dbStats.indexSize

The total size of all indexes created on this database. The
``scale`` arguments affects this value.

.. uses the dataSize member

.. data:: dbStats.fileSize

The total size of the data files that hold the database. This value
includes preallocated space and the :term:`padding factor`. The
value of :data:`~dbStats.fileSize` only reflects the size of the data files
for the database and not the namespace file.

The ``scale`` argument affects this value.

.. data:: dbStats.nsSizeMB

The total size of the :term:`namespace` files (i.e. that end with
``.ns``) for this database. You cannot change the size of the
namespace file after creating a database, but you can change the
default size for all new namespace files with the
:setting:`nssize` runtime option.

.. seealso:: The :setting:`nssize` option, and :ref:`Maximum Namespace File Size <limit-size-of-namespace-file>`

.. data:: dbStats.dataFileVersion

.. versionadded:: 2.4

Document that contains information about the on-disk format of the data
files for the database.

.. data:: dbStats.dataFileVersion.major

.. versionadded:: 2.4

The major version number for the on-disk format of the data files for
the database.

.. data:: dbStats.dataFileVersion.minor

.. versionadded:: 2.4

The minor version number for the on-disk format of the data files for
the database.
144 changes: 0 additions & 144 deletions source/reference/database-statistics.txt

This file was deleted.

15 changes: 9 additions & 6 deletions source/reference/method/db.stats.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ db.stats()
the database system's state.

This function provides a wrapper around the database command
":dbcommand:`dbStats`". The ``scale`` option allows you to
configure how the :program:`mongo` shell scales the sizes
of things in the output. For example, specify a ``scale``
value of ``1024`` to display kilobytes rather than bytes.
:dbcommand:`dbStats`.

See the ":doc:`/reference/database-statistics`" document for an
overview of this output.
To convert the returned values to kilobytes, use the scale argument:

.. code-block:: javascript

db.stats(1024)

The :doc:`dbStats command </reference/command/dbStats>` document
describes the fields in the :method:`db.stats()` output.

.. note::

Expand Down
2 changes: 1 addition & 1 deletion source/reference/mongostat.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ UNIX/Linux file system utility ``vmstat``, but provides data regarding

- :doc:`/reference/command/serverStatus`
- :doc:`/reference/replica-status`
- :doc:`/reference/database-statistics`
- :doc:`/reference/command/dbStats`
- :doc:`/reference/command/collStats`

For an additional utility that provides MongoDB metrics see
Expand Down
2 changes: 1 addition & 1 deletion source/reference/mongotop.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ provides statistics on a per-collection level. By default,

- :doc:`/reference/command/serverStatus`
- :doc:`/reference/replica-status`
- :doc:`/reference/database-statistics`
- :doc:`/reference/command/dbStats`
- :doc:`/reference/command/collStats`

For an additional utility that provides MongoDB metrics
Expand Down
3 changes: 1 addition & 2 deletions source/tutorial/copy-databases-between-instances.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ Considerations
free disk space on the destination server for the database you are
copying. Use the :method:`db.stats()` operation to check the size of
the database on the source :program:`mongod` instance. For more
information on the output of :method:`db.stats()` see
:doc:`/reference/database-statistics` document.
information, see :method:`db.stats()`.

Processes
---------
Expand Down