12
12
13
13
.. dbcommand:: top
14
14
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.
29
18
30
19
.. important::
31
20
32
21
The :dbcommand:`top` command must be run against a
33
22
:doc:`mongod </reference/program/mongod>` instance. Running
34
23
:dbcommand:`top` against a :doc:`mongos </reference/program/mongos>`
35
- instance will return an error.
24
+ instance returns an error.
36
25
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.
39
34
40
35
Syntax
41
36
------
42
37
43
- The command has the following syntax :
38
+ Issue the :dbcommand:`top` command against the :term:`admin database` :
44
39
45
40
.. code-block:: javascript
46
41
@@ -50,30 +45,78 @@ The command has the following syntax:
50
45
}
51
46
)
52
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``.
53
109
54
110
Example
55
111
-------
56
112
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:
72
114
73
115
.. code-block:: javascript
74
116
75
117
{
76
118
"totals" : {
119
+ note: "all times in microseconds",
77
120
"records.users" : {
78
121
"total" : {
79
122
"time" : 305277,
@@ -113,3 +156,8 @@ output:
113
156
}
114
157
}
115
158
}
159
+
160
+ Learn More
161
+ ----------
162
+
163
+ - :ref:`faq-concurrency-locking`
0 commit comments