Skip to content

Commit 9019406

Browse files
authored
DOCS-15983 Top Command Paramenters (#2754) (#2841)
* 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 aa7a1a6 commit 9019406

File tree

1 file changed

+81
-33
lines changed

1 file changed

+81
-33
lines changed

source/reference/command/top.txt

Lines changed: 81 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,30 @@ 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`.
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

4035
Syntax
4136
------
4237

43-
The command has the following syntax:
38+
Issue the :dbcommand:`top` command against the :term:`admin database`:
4439

4540
.. code-block:: javascript
4641

@@ -50,30 +45,78 @@ The command has the following syntax:
5045
}
5146
)
5247

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``.
53109

54110
Example
55111
-------
56112

57-
At :binary:`~bin.mongosh` prompt, use :dbcommand:`top` with the
58-
following invocation:
59-
60-
.. code-block:: javascript
61-
62-
db.adminCommand("top")
63-
64-
Alternately you can use :dbcommand:`top` as follows:
65-
66-
.. code-block:: javascript
67-
68-
db.adminCommand( { top: 1 } )
69-
70-
The output of the top command would resemble the following
71-
output:
113+
The output of the :dbcommand:`top` command resembles the following output:
72114

73115
.. code-block:: javascript
74116

75117
{
76118
"totals" : {
119+
note: "all times in microseconds",
77120
"records.users" : {
78121
"total" : {
79122
"time" : 305277,
@@ -113,3 +156,8 @@ output:
113156
}
114157
}
115158
}
159+
160+
Learn More
161+
----------
162+
163+
- :ref:`faq-concurrency-locking`

0 commit comments

Comments
 (0)