db.collection.latencyStats()
On this page本页内容
Definition定义
db.collection.latencyStats(options)
- Important
mongosh Method
This page documents a
mongosh
method. This is not the documentation for database commands or language-specific drivers, such as Node.js.For the database command, see the
latencyStats
field returned by thecollStats
command.For MongoDB API drivers, refer to the language-specific MongoDB driver documentation.
For the legacy
mongo
shell documentation, refer to the documentation for the corresponding MongoDB Server release: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> } )
Thehistograms
argument is an optional boolean.histograms
参数是一个可选的布尔值。If如果histograms: true
thenlatencyStats()
adds latency histograms to the return document.histograms: true
,则latencyStats()
将延迟直方图添加到返回文档中。
See also: 另请参阅:
Output输出
latencyStats()
returns a document containing a field 返回一个包含字段latencyStats
, containing the following fields:latencyStats
的文档,该字段包含以下字段:
reads | |
writes | |
commands | |
transactions |
Each of these fields contains an embedded document bearing the following fields:这些字段中的每一个都包含一个嵌入文档,其中包含以下字段:
latency | |||||||
ops | |||||||
histogram | latencyStats: { histograms: true } option. latencyStats: { histograms: true } 选项的情况下存在。count are omitted from the output.count 为零的空范围。
histogram: [
|
[1] |
|
Examples实例
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)
}
}
}