db.collection.latencyStats()
Definition
mongo
Shell Method
This page documents the mongo
shell method, and doesnot refer to the MongoDB Node.js driver (or any other driver)method. For corresponding MongoDB driver API, refer to your specificMongoDB driver documentation instead.
db.collection.latencyStats()
returns latencystatistics for a given collection. It is a wrapper around$collStats
.
This method has the form:
- db.collection.latencyStats( { histograms: <boolean> } )
The histograms
argument is an optional boolean. Ifhistograms: true
then latencyStats()
addslatency histograms to the return document.
See also
Output
latencyStats()
returns a document containinga field latencyStats
, containing the following fields:
Field Name | Description |
---|---|
reads | Latency statistics for read requests. |
writes | Latency statistics for write requests. |
commands | Latency statistics for database commands. |
Each of these fields contains an embedded document bearing thefollowing fields:
Field Name | Description | ||||||
---|---|---|---|---|---|---|---|
latency | A 64-bit integer giving the total combinedlatency in microseconds. | ||||||
ops | A 64-bit integer giving the total number ofoperations performed on the collection since startup. | ||||||
histogram | An array of embedded documents, each representing a latency range.Each document covers twice the previous document’s range. Forupper values between 2048 microseconds and roughly 1 second,the histogram includes half-steps.This field only exists given thelatencyStats: { histograms: true } option. Empty ranges witha zero count are omitted from the output.Each document bears the following fields:
For example, if
This indicates that there were:
|
Examples
You can run latencyStats()
in a mongo
shell as follows:
- db.data.latencyStats( { histograms: true } ).pretty()
latencyStats()
returns a document such asthe following:
- {
- "ns" : "test.data",
- "localTime" : ISODate("2016-11-01T21:56:28.962Z"),
- "latencyStats" : {
- "reads" : {
- "histogram" : [
- {
- "micros" : NumberLong(16),
- "count" : NumberLong(6)
- },
- {
- "micros" : NumberLong(512),
- "count" : NumberLong(1)
- }
- ],
- "latency" : NumberLong(747),
- "ops" : NumberLong(7)
- },
- "writes" : {
- "histogram" : [
- {
- "micros" : NumberLong(64),
- "count" : NumberLong(1)
- },
- {
- "micros" : NumberLong(24576),
- "count" : NumberLong(1)
- }
- ],
- "latency" : NumberLong(26845),
- "ops" : NumberLong(2)
- },
- "commands" : {
- "histogram" : [ ],
- "latency" : NumberLong(0),
- "ops" : NumberLong(0)
- }
- }
- }