top
top
top
is an administrative command that returns usage statistics for each collection. You can usetop
metrics to compare the relative performance of your collections against each other.
Definition
For every collection, top
returns the amount of time
, in
microseconds, that each event takes to execute and a
count
of how many times each event has executed. The time
and
count
metrics reset only after you restart your mongod
instance.
Redaction
When using Queryable Encryption, the
top
command only returns the collection name.
Compatibility
This command is available in deployments hosted in the following environments:
MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
Important
This command is not supported in serverless instances. For more information, see Unsupported Commands.
MongoDB Enterprise: The subscription-based, self-managed version of MongoDB
MongoDB Community: The source-available, free-to-use, and self-managed version of MongoDB
Syntax
Issue the top
command against the admin database:
db.runCommand( { top: 1 } )
Event Fields
The top
command returns usage statistics for the following event
fields:
Field | Description |
---|---|
| The combination of all |
| Usage statistics for operations that use read locks. These operations include but are not limited to queries and aggregations. |
| Usage statistics for operations that use write locks. These operations include but are not limited to inserting, updating, and removing documents. |
| Usage statistics for query operations such as |
| Usage statistics for |
| Usage statistics for |
| Usage statistics for |
| Usage statistics for |
| Usage statistics for operations such as aggregations, index creation,
and index removal. Depending on the type of command, the
For example, aggregation operations increment |
Example
The output of the top
command resembles the following output:
{ "totals" : { note: "all times in microseconds", "records.users" : { "total" : { "time" : 305277, "count" : 2825 }, "readLock" : { "time" : 305264, "count" : 2824 }, "writeLock" : { "time" : 13, "count" : 1 }, "queries" : { "time" : 305264, "count" : 2824 }, "getmore" : { "time" : 0, "count" : 0 }, "insert" : { "time" : 0, "count" : 0 }, "update" : { "time" : 0, "count" : 0 }, "remove" : { "time" : 0, "count" : 0 }, "commands" : { "time" : 0, "count" : 0 } } }