On this page
db.collection.latencyStats()
在本页面
Definition
db.collection.
latencyStats
(* options *)- db.collection.latencyStats()返回给定集合的延迟统计信息。它是围绕$collStats的包装。
此方法的形式为:
db.collection.latencyStats( { histograms: <boolean> } )
histograms
参数是一个可选的布尔值。如果histograms: true
,则latencyStats()将延迟直方图添加到返回文档中。
See also
Output
latencyStats()返回包含字段latencyStats
的文档,该字段包含以下字段:
Field Name | Description |
---|---|
reads |
读取请求的延迟统计信息。 |
writes |
写入请求的延迟统计信息。 |
commands |
数据库命令的延迟统计信息。 |
每个字段都包含一个嵌入的文档,其中包含以下字段:
Field Name | Description | |||||||
---|---|---|---|---|---|---|---|---|
latency |
long给出总的组合延迟(以微秒为单位)。 | |||||||
ops |
long给出自启动以来对集合执行的操作总数。 | |||||||
histogram |
一组嵌入式文档,每个文档代表一个 await 时间范围。每个文档覆盖先前文档范围的两倍。对于 2048 微秒到大约 1 秒之间的较高值,直方图包括半步。 | |||||||
仅提供 latencyStats: { histograms: true } 选项后,此字段才存在。输出中省略带有零count 的空范围。每个文档都包含以下字段: |
栏位名称 | 描述 |
micros |
long给出了当前 await 时间范围的上限时间(以微秒为单位)。 该文档的范围介于上一个文档的 micros 值(不包括此值)和该文档的micros 值(包括一个值)之间。 |
count |
long给出了延迟时间小于或等于micros 的操作数。 |
例如,如果 collStats 返回以下直方图: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) } |
br]
这表明有:
10 操作耗时不超过 1 微秒,
1 操作的范围为(1、2]微秒,
1 操作范围为(3072,4096]微秒,
1000 范围(12288,16384)的操作,以及
100 个操作在(32768,49152]范围内。
Examples
您可以在mongo shell 中运行latencyStats(),如下所示:
db.data.latencyStats( { histograms: true } ).pretty()
latencyStats()返回如下文件:
{
"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)
}
}
}