Skip to content

Commit 8f19ac5

Browse files
Bob GrabarSam Kleinman
authored andcommitted
DOCS-1184 indexStats() command
Signed-off-by: Sam Kleinman <[email protected]>
1 parent 63f89cd commit 8f19ac5

File tree

6 files changed

+442
-1
lines changed

6 files changed

+442
-1
lines changed

source/core/indexes.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,39 @@ the ``a`` field.
567567
.. [#hash-size] The hash stored in the ``hashed`` index is 64 bits of the
568568
128 bit ``md5`` hash.
569569

570+
.. index:: index; name
571+
.. _index-names:
572+
573+
Index Names
574+
-----------
575+
576+
The default name for an index is the concatenation of the indexed keys
577+
and each key's direction in the index (1 or -1).
578+
579+
.. example:: Issue the following command to create an index on ``item``
580+
and ``quantity``:
581+
582+
.. code-block:: javascript
583+
584+
db.products.ensureIndex( { item: 1, quantity: -1 } )
585+
586+
The resulting index is named: ``item_1_quantity_-1``.
587+
588+
Optionally. you can specify a name for an index instead of using the
589+
default name.
590+
591+
.. example:: Issue the following command to create an index on ``item``
592+
and ``quantity`` and specify ``inventory`` as the index name:
593+
594+
.. code-block:: javascript
595+
596+
db.products.ensureIndex( { item: 1, quantity: -1 } , {name: "inventory"} )
597+
598+
The resulting index is named: ``inventory``.
599+
600+
To view the name of an index, use the :method:`getIndexes()
601+
<db.collection.getIndexes()>` method.
602+
570603
.. index:: index; options
571604
.. _index-creation-operations:
572605
.. _index-operations:

source/reference.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Status and Reporting
4444
reference/database-profiler
4545
reference/explain
4646
reference/exit-codes
47+
reference/index-stats
4748

4849
Internal Metadata
4950
-----------------
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
==========
2+
indexStats
3+
==========
4+
5+
.. default-domain:: mongodb
6+
7+
.. dbcommand:: indexStats
8+
9+
The :dbcommand:`indexStats` command aggregates statistics
10+
for the B-tree data structure that stores data for a MongoDB index.
11+
12+
.. warning:: This command is not intended for production deployments.
13+
14+
The command can be run *only* on a :program:`mongod` instance that uses
15+
the ``--enableExperimentalIndexStatsCmd`` option.
16+
17+
To aggregate statistics, issue the command like so:
18+
19+
.. code-block:: javascript
20+
21+
db.runCommand( { indexStats: "<collection>", index: "<index name>" } )
22+
23+
For more information on the command's limits and output, see the following:
24+
25+
- The equivalent :method:`db.collection.indexStats()` method
26+
27+
- :doc:`/reference/index-stats`
28+
29+
- `https://github.com/10gen-labs/storage-viz#readme <https://github.com/10gen-labs/storage-viz#readme>`_.

0 commit comments

Comments
 (0)