Skip to content

Commit 66a8418

Browse files
authored
DOCS-15983 Top Command Paramenters (#2754) (#2846)
* WIP * DOCS-15983 Add Parameter Details for Top Command * event type descriptions * move to table * fix text styling and wording * build errors * typo * change wording for event fields * JD edits * JD edits pt 2
1 parent cd7c5f6 commit 66a8418

File tree

1 file changed

+91
-34
lines changed

1 file changed

+91
-34
lines changed

source/reference/command/top.txt

Lines changed: 91 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,59 +12,111 @@ top
1212

1313
.. dbcommand:: top
1414

15-
:dbcommand:`top` is an administrative command that
16-
returns usage statistics for each collection. :dbcommand:`top`
17-
provides amount of time, in microseconds, used and a count of
18-
operations for the following event types:
19-
20-
- total
21-
- readLock
22-
- writeLock
23-
- queries
24-
- getmore
25-
- insert
26-
- update
27-
- remove
28-
- commands
15+
:dbcommand:`top` is an administrative command that returns usage statistics
16+
for each collection. You can use :dbcommand:`top` metrics to compare the
17+
relative performance of your collections against each other.
2918

3019
.. important::
3120

3221
The :dbcommand:`top` command must be run against a
3322
:doc:`mongod </reference/program/mongod>` instance. Running
3423
:dbcommand:`top` against a :doc:`mongos </reference/program/mongos>`
35-
instance will return an error.
24+
instance returns an error.
3625

37-
Issue the :dbcommand:`top` command against the :term:`admin
38-
database` in the form:
26+
Definition
27+
----------
28+
29+
For every collection, :dbcommand:`top` returns the amount of ``time``, in
30+
microseconds, that each :ref:`event <event-types>` takes to execute and a
31+
``count`` of how many times each event has executed. The ``time`` and
32+
``count`` metrics reset only after you restart your :binary:`~bin.mongod`
33+
instance.
3934

40-
.. code-block:: javascript
35+
Syntax
36+
------
4137

42-
{ top: 1 }
43-
44-
45-
Example
46-
-------
47-
48-
At the :binary:`~bin.mongo` shell prompt, use :dbcommand:`top` with the
49-
following invocation:
38+
Issue the :dbcommand:`top` command against the :term:`admin database`:
5039

5140
.. code-block:: javascript
5241

53-
db.adminCommand("top")
54-
55-
Alternately you can use :dbcommand:`top` as follows:
42+
db.runCommand(
43+
{
44+
top: 1
45+
}
46+
)
47+
48+
.. _event-types:
49+
50+
Event Fields
51+
------------
52+
53+
The :dbcommand:`top` command returns usage statistics for the following event
54+
fields:
55+
56+
.. list-table::
57+
:header-rows: 1
58+
:widths: 20 80
59+
60+
* - Field
61+
- Description
62+
63+
* - ``total``
64+
- The combination of all ``readLock`` and ``writeLock`` operations.
65+
66+
* - ``readLock``
67+
- Usage statistics for operations that use read locks. These operations
68+
include but are not limited to queries and aggregations.
69+
70+
* - ``writeLock``
71+
- Usage statistics for operations that use write locks. These operations
72+
include but are not limited to inserting, updating, and removing
73+
documents.
74+
75+
* - ``queries``
76+
- Usage statistics for query operations such as :dbcommand:`find`. The
77+
``queries.time`` and ``queries.count`` fields also update
78+
``readLock.time`` and increment ``readLock.count``.
79+
80+
* - ``getmore``
81+
- Usage statistics for :dbcommand:`getMore` operations. The
82+
``getmore.time`` and ``getmore.count`` fields also update
83+
``readLock.time`` and increment ``readLock.count``.
84+
85+
* - ``insert``
86+
- Usage statistics for :dbcommand:`insert` operations. The
87+
``insert.time`` and ``insert.count`` fields also update
88+
``readLock.time`` and increment ``readLock.count``.
89+
90+
* - ``update``
91+
- Usage statistics for :dbcommand:`update` operations. The
92+
``update.time`` and ``update.count`` fields also update
93+
``readLock.time`` and increment ``readLock.count``.
94+
95+
* - ``remove``
96+
- Usage statistics for :dbcommand:`delete` operations. The
97+
``remove.time`` and ``remove.count`` fields also update
98+
``readLock.time`` and increment ``readLock.count``.
99+
100+
* - ``commands``
101+
- Usage statistics for operations such as aggregations, index creation,
102+
and index removal. Depending on the type of command, the
103+
``commands.time`` and ``commands.count`` fields update the ``writeLock``
104+
fields or the ``readLock`` fields.
105+
106+
For example, aggregation operations increment ``readLock.time`` and
107+
``readLock.count``. Index creation increments ``writeLock.time``
108+
and ``writeLock.count``.
56109

57-
.. code-block:: javascript
58-
59-
db.adminCommand( { top: 1 } )
110+
Example
111+
-------
60112

61-
The output of the top command would resemble the following
62-
output:
113+
The output of the :dbcommand:`top` command resembles the following output:
63114

64115
.. code-block:: javascript
65116

66117
{
67118
"totals" : {
119+
note: "all times in microseconds",
68120
"records.users" : {
69121
"total" : {
70122
"time" : 305277,
@@ -104,3 +156,8 @@ output:
104156
}
105157
}
106158
}
159+
160+
Learn More
161+
----------
162+
163+
- :ref:`faq-concurrency-locking`

0 commit comments

Comments
 (0)