On this page本页内容
db.collection.latencyStats(options)
This is a mongosh
method. This is not the documentation for Node.js
or other programming language specific driver methods.
In most cases, mongosh
methods work the same way as the legacy mongo
shell methods. However, some legacy methods are unavailable in mongosh
.
For the legacy mongo
shell documentation, refer to the documentation for the corresponding MongoDB Server release:
For MongoDB API drivers, refer to the language specific MongoDB driver documentation.
db.collection.latencyStats()
returns latency statistics for a given collection. 返回给定集合的延迟统计信息。It is a wrapper around 它是$collStats
.$collStats
的包装。
This method has the form:此方法具有以下形式:
db.collection.latencyStats( { histograms: <boolean> } )
The histograms
argument is an optional boolean. histograms
参数是可选的布尔值。If 如果histograms: true
then latencyStats()
adds latency histograms to the return document.histograms: true
,则latencyStats()
将延迟直方图添加到返回文档中。
latencyStats()
returns a document containing a field 返回包含字段latencyStats
, containing the following fields:latencyStats
的文档,该字段包含以下字段:
reads | |
writes | |
commands |
Each of these fields contains an embedded document bearing the following fields:每个字段都包含一个嵌入文档,其中包含以下字段:
latency | |||||||||
ops | |||||||||
histogram |
histogram: [ { micros: NumberLong(1), count: NumberLong(10) }, { micros: NumberLong(2), count: NumberLong(1) }, { micros: NumberLong(4096), count: NumberLong(1) }, { micros: NumberLong(16384), count: NumberLong(1000) }, { micros: NumberLong(49152), count: NumberLong(100) } ]
|
You can run 您可以在latencyStats()
in mongosh
as follows:mongosh
中运行latencyStats()
,如下所示:
db.data.latencyStats( { histograms: true } ).pretty()
latencyStats()
returns a document such as the 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) } } }