diff --git a/bin/htaccess.yaml b/bin/htaccess.yaml index d9a02e8f353..77436a268f6 100644 --- a/bin/htaccess.yaml +++ b/bin/htaccess.yaml @@ -1438,6 +1438,14 @@ redirect-path: '/reference/commands' url-base: '/reference/command' type: 'redirect' code: 301 +outputs: + - 'after-v2.2' + - 'manual' +--- +redirect-path: '/reference/collection-statistics' +url-base: '/reference/command/collStats' +type: 'redirect' +code: 301 outputs: - 'after-v2.2' - 'manual' diff --git a/source/administration/monitoring.txt b/source/administration/monitoring.txt index 9ea828458eb..b8864ef4785 100644 --- a/source/administration/monitoring.txt +++ b/source/administration/monitoring.txt @@ -136,7 +136,7 @@ utilization between databases and to determine average ``collStats`` ````````````` -The :doc:`collStats data ` is +The :doc:`collStats data ` is accessible using the :dbcommand:`collStats` command (:method:`db.printCollectionStats()` from the shell). It provides statistics that resemble :dbcommand:`dbStats` on the collection level: diff --git a/source/core/document.txt b/source/core/document.txt index b3c0591064f..88cd5ce1379 100644 --- a/source/core/document.txt +++ b/source/core/document.txt @@ -32,7 +32,7 @@ MongoDB contexts: - the output of a number of MongoDB commands and operations, including: - - the :doc:`output ` + - the output of :dbcommand:`collStats` command, and - the :doc:`output ` of the diff --git a/source/meta/reference.txt b/source/meta/reference.txt index c7f71fd4962..3c5ff61eb6d 100644 --- a/source/meta/reference.txt +++ b/source/meta/reference.txt @@ -70,7 +70,7 @@ Status, Monitoring, and Reporting Output /reference/command/serverStatus /reference/database-statistics - /reference/collection-statistics + /reference/command/collStats /reference/connection-pool-stats /reference/replica-status /reference/exit-codes diff --git a/source/reference.txt b/source/reference.txt index 37d2b9eb486..48c1a7f5696 100644 --- a/source/reference.txt +++ b/source/reference.txt @@ -36,7 +36,7 @@ Status and Reporting :maxdepth: 1 reference/database-statistics - reference/collection-statistics + reference/command/collStats reference/collection-validation reference/connection-pool-stats reference/current-op diff --git a/source/reference/collection-statistics.txt b/source/reference/collection-statistics.txt deleted file mode 100644 index 86cb0cbfa6a..00000000000 --- a/source/reference/collection-statistics.txt +++ /dev/null @@ -1,177 +0,0 @@ -=============================== -Collection Statistics Reference -=============================== - -.. default-domain:: mongodb -.. highlight:: javascript - -Synopsis --------- - -To fetch collection statistics, call the :method:`db.collection.stats()` method on -a collection object in the :program:`mongo` shell: - -.. code-block:: javascript - - db.collection.stats() - -You may also use the literal command format: - -.. code-block:: javascript - - db.runCommand( { collStats: "collection" } ) - -Replace ``collection`` in both examples with the name of the -collection you want statistics for. By default, the return values will -appear in terms of bytes. You can, however, enter a ``scale`` -argument. For example, you can convert the return values to kilobytes -like so: - -.. code-block:: javascript - - db.collection.stats(1024) - -Or: - -.. code-block:: javascript - - db.runCommand( { collStats: "collection", scale: 1024 } ) - -.. note:: - - The ``scale`` argument rounds values to whole numbers. This can - produce unpredictable and unexpected results in some situations. - -.. seealso:: The documentation of the ":dbcommand:`collStats`" command - and the ":method:`db.collection.stats()`," method in the :program:`mongo` shell. - -Example Document ----------------- - -The output of :method:`db.collection.stats()` resembles the following: - -.. code-block:: javascript - - { - "ns" : ".", - "count" : , - "size" : , - "avgObjSize" : , - "storageSize" : , - "numExtents" : , - "nindexes" : , - "lastExtentSize" : , - "paddingFactor" : , - "systemFlags" : , - "userFlags" : , - "totalIndexSize" : , - "indexSizes" : { - "_id_" : , - "a_1" : - }, - "ok" : 1 - } - -Fields ------- - -.. data:: collStats.ns - - The namespace of the current collection, which follows the format - ``[database].[collection]``. - -.. data:: collStats.count - - The number of objects or documents in this collection. - -.. data:: collStats.size - - The size of the data stored in this collection. This value does not - include the size of any indexes associated with the collection, - which the :data:`~collStats.totalIndexSize` field reports. - - The ``scale`` argument affects this value. - -.. data:: collStats.avgObjSize - - The average size of an object in the collection. The ``scale`` - argument affects this value. - -.. data:: collStats.storageSize - - The total amount of storage allocated to this collection for - :term:`document` storage. The ``scale`` argument affects this - value. The :data:`~collStats.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:: collStats.numExtents - - The total number of contiguously allocated data file regions. - -.. data:: collStats.nindexes - - The number of indexes on the collection. All collections have at - least one index on the :term:`_id` field. - - .. versionchanged:: 2.2 - Before 2.2, capped collections did not necessarily have an - index on the ``_id`` field, and some capped collections created - with pre-2.2 versions of :program:`mongod` may not have an - ``_id`` index. - - -.. data:: collStats.lastExtentSize - - The size of the last extent allocated. The ``scale`` argument - affects this value. - -.. data:: collStats.paddingFactor - - The amount of space added to the end of each document at insert - time. The document padding provides a small amount of extra space - on disk to allow a document to grow slightly without needing to - move the document. :program:`mongod` automatically calculates this - padding factor - -.. data:: collStats.flags - - .. versionchanged:: 2.2 - Removed in version 2.2 and replaced with the :data:`~collStats.userFlags` - and :data:`~collStats.systemFlags` fields. - - Indicates the number of flags on the current collection. In version - 2.0, the only flag notes the existence of an :term:`index` on the - :term:`_id` field. - -.. data:: collStats.systemFlags - - .. versionadded:: 2.2 - - Reports the flags on this collection that reflect internal server - options. Typically this value is ``1`` and reflects the existence - of an :term:`index` on the ``_id`` field. - -.. data:: collStats.userFlags - - .. versionadded:: 2.2 - - 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``. - - See the :dbcommand:`collMod` command for more information on setting user - flags and :collflag:`usePowerOf2Sizes`. - -.. data:: collStats.totalIndexSize - - The total size of all indexes. The ``scale`` argument affects this - value. - -.. data:: collStats.indexSizes - - This field specifies the key and size of every existing index on - the collection. The ``scale`` argument affects this value. diff --git a/source/reference/command/collStats.txt b/source/reference/command/collStats.txt index a5bef305aae..0ff87e0fcd1 100644 --- a/source/reference/command/collStats.txt +++ b/source/reference/command/collStats.txt @@ -4,6 +4,9 @@ collStats .. default-domain:: mongodb +Definition +---------- + .. dbcommand:: collStats The :dbcommand:`collStats` command returns a variety of storage statistics @@ -47,6 +50,134 @@ collStats The scale factor rounds values to whole numbers. This can produce unpredictable and unexpected results in some situations. - .. seealso:: ":doc:`/reference/collection-statistics`." +Output +------ + +.. data:: collStats.ns + + The namespace of the current collection, which follows the format + ``[database].[collection]``. + +.. data:: collStats.count + + The number of objects or documents in this collection. + +.. data:: collStats.size + + The size of the data stored in this collection. This value does not + include the size of any indexes associated with the collection, + which the :data:`~collStats.totalIndexSize` field reports. + + The ``scale`` argument affects this value. + +.. data:: collStats.avgObjSize + + The average size of an object in the collection. The ``scale`` + argument affects this value. + +.. data:: collStats.storageSize + + The total amount of storage allocated to this collection for + :term:`document` storage. The ``scale`` argument affects this + value. The :data:`~collStats.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:: collStats.numExtents + + The total number of contiguously allocated data file regions. + +.. data:: collStats.nindexes + + The number of indexes on the collection. All collections have at + least one index on the :term:`_id` field. + + .. versionchanged:: 2.2 + Before 2.2, capped collections did not necessarily have an + index on the ``_id`` field, and some capped collections created + with pre-2.2 versions of :program:`mongod` may not have an + ``_id`` index. + + +.. data:: collStats.lastExtentSize + + The size of the last extent allocated. The ``scale`` argument + affects this value. + +.. data:: collStats.paddingFactor + + The amount of space added to the end of each document at insert + time. The document padding provides a small amount of extra space + on disk to allow a document to grow slightly without needing to + move the document. :program:`mongod` automatically calculates this + padding factor + +.. data:: collStats.flags + + .. versionchanged:: 2.2 + Removed in version 2.2 and replaced with the :data:`~collStats.userFlags` + and :data:`~collStats.systemFlags` fields. + + Indicates the number of flags on the current collection. In version + 2.0, the only flag notes the existence of an :term:`index` on the + :term:`_id` field. + +.. data:: collStats.systemFlags + + .. versionadded:: 2.2 + + Reports the flags on this collection that reflect internal server + options. Typically this value is ``1`` and reflects the existence + of an :term:`index` on the ``_id`` field. + +.. data:: collStats.userFlags + + .. versionadded:: 2.2 + + 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``. + + See the :dbcommand:`collMod` command for more information on setting user + flags and :collflag:`usePowerOf2Sizes`. + +.. data:: collStats.totalIndexSize + + The total size of all indexes. The ``scale`` argument affects this + value. + +.. data:: collStats.indexSizes + + 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 - .. read-lock + { + "ns" : ".", + "count" : , + "size" : , + "avgObjSize" : , + "storageSize" : , + "numExtents" : , + "nindexes" : , + "lastExtentSize" : , + "paddingFactor" : , + "systemFlags" : , + "userFlags" : , + "totalIndexSize" : , + "indexSizes" : { + "_id_" : , + "a_1" : + }, + "ok" : 1 + } diff --git a/source/reference/method/db.collection.stats.txt b/source/reference/method/db.collection.stats.txt index 1ff11d69637..324eb980768 100644 --- a/source/reference/method/db.collection.stats.txt +++ b/source/reference/method/db.collection.stats.txt @@ -27,5 +27,5 @@ db.collection.stats() db.people.stats() - .. seealso:: ":doc:`/reference/collection-statistics`" for an + .. seealso:: :doc:`/reference/command/collStats` for an overview of the output of this command. diff --git a/source/reference/method/db.printCollectionStats.txt b/source/reference/method/db.printCollectionStats.txt index d2c6e43b6bf..d12c05a831d 100644 --- a/source/reference/method/db.printCollectionStats.txt +++ b/source/reference/method/db.printCollectionStats.txt @@ -16,4 +16,4 @@ db.printCollectionStats() .. include:: /includes/note-method-does-not-return-json.rst - .. seealso:: ":doc:`/reference/collection-statistics`" + .. seealso:: :doc:`/reference/command/collStats` diff --git a/source/reference/mongostat.txt b/source/reference/mongostat.txt index a56f1cf26d9..eb76558d8c5 100644 --- a/source/reference/mongostat.txt +++ b/source/reference/mongostat.txt @@ -27,7 +27,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/collection-statistics` + - :doc:`/reference/command/collStats` For an additional utility that provides MongoDB metrics see ":doc:`mongotop `." diff --git a/source/reference/mongotop.txt b/source/reference/mongotop.txt index 055a84606f4..a91a2b42785 100644 --- a/source/reference/mongotop.txt +++ b/source/reference/mongotop.txt @@ -25,7 +25,7 @@ provides statistics on a per-collection level. By default, - :doc:`/reference/command/serverStatus` - :doc:`/reference/replica-status` - :doc:`/reference/database-statistics` - - :doc:`/reference/collection-statistics` + - :doc:`/reference/command/collStats` For an additional utility that provides MongoDB metrics see ":doc:`mongostat `." diff --git a/source/tutorial/ensure-indexes-fit-ram.txt b/source/tutorial/ensure-indexes-fit-ram.txt index fbf1138e484..1b767634fff 100644 --- a/source/tutorial/ensure-indexes-fit-ram.txt +++ b/source/tutorial/ensure-indexes-fit-ram.txt @@ -30,9 +30,7 @@ fit in memory at the same time. There are some limited cases where indexes do not need to fit in memory. See :ref:`indexing-right-handed`. -.. seealso:: For additional :doc:`collection statistics - `, use :dbcommand:`collStats` or - :method:`db.collection.stats()`. +.. seealso:: :dbcommand:`collStats` and :method:`db.collection.stats()` .. _indexing-right-handed: