AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

db.コレクション.latencyStats()(mongoshメソッド)

重要

mongosh メソッド

This page documents a mongosh method. This is not the documentation for database commands or language-specific drivers, such as Node.js.

データベースコマンドについては、 collStatsコマンドによって返されるlatencyStatsフィールドを参照してください。

MongoDB API ドライバーについては、各言語の「MongoDB ドライバーのドキュメント」を参照してください。

db.collection.latencyStats(options)

db.collection.latencyStats() returns latency statistics for a given collection. It is a wrapper around $collStats.

このメソッドの形式は次のとおりです。

db.collection.latencyStats( { histograms: <boolean> } )

The histograms argument is an optional boolean. If histograms: true then latencyStats() adds latency histograms to the return document.

このメソッドは、次の環境でホストされている配置で使用できます。

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

注意

This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.

  • MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン

  • MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン

latencyStats() returns a document containing a field latencyStats, containing the following fields:

フィールド名
説明

reads

読み取りリクエストのレイテンシ統計

writes

書込み (write) リクエストのレイテンシ統計

commands

データベースコマンドのレイテンシ統計

transactions

データベース トランザクションのレイテンシ統計です。

これらの各フィールドには、次のフィールドを持つ埋め込みドキュメントが含まれています。

フィールド名
説明

latency

合計レイテンシ(マイクロ秒単位)。

ops

のスタートアップ以降にコレクションに対して実行された操作の合計数。

histogram

それぞれがレイテンシ範囲を表す埋め込みドキュメントの配列。 各ドキュメントは、前のドキュメントの範囲の 2 倍をカバーします。 2048マイクロ秒から約1秒の間の低い値の場合、ヒストグラムには半ステップが含まれます。

このフィールドは、 latencyStats: { histograms: true }オプションでのみ存在します。 ゼロのcountがある空の範囲は出力から省略されます。

各ドキュメントには、次のフィールドがあります。

  • micros:現在のレイテンシ範囲の包括的な下限(マイクロ秒単位)。

    ドキュメントの範囲は、前のドキュメントのmicros値(排他的)とこのドキュメントのmicros値(包括的)の間です。

  • count: レイテンシが micros 以下の操作の数。

たとえば、 collStatsが次のヒストグラムを返す場合、次のようになります。

histogram: [
{ micros: Long(0), count: Long(10) },
{ micros: Long(2), count: Long(1) },
{ micros: Long(4096), count: Long(1) },
{ micros: Long(16384), count: Long(1000) },
{ micros: Long(49152), count: Long(100) }
]

This indicates that there were [1]:

  • マイクロ秒以下を使用する10 操作2

  • 範囲 [ 2 、 4 )マイクロ秒の1操作

  • 範囲 [ 4096 、 6144 )マイクロ秒の1操作

  • 範囲 [ 16384 、 24576 )マイクロ秒の1000操作

  • 範囲 [ 49152 、 65536 )マイクロ秒の100操作

[1]
  • このページの(記号表記は、値が排他的であることを意味します。

  • このページの]記号表記は、値が包括的であることを意味します。

You can run latencyStats() in mongosh as follows:

db.data.latencyStats( { histograms: true } ).pretty()

latencyStats() は、次のようなドキュメントを返します。

{
"ns" : "test.data",
"localTime" : ISODate("2016-11-01T21:56:28.962Z"),
"latencyStats" : {
"reads" : {
"histogram" : [
{
"micros" : Long(16),
"count" : Long(6)
},
{
"micros" : Long(512),
"count" : Long(1)
}
],
"latency" : Long(747),
"ops" : Long(7)
},
"writes" : {
"histogram" : [
{
"micros" : Long(64),
"count" : Long(1)
},
{
"micros" : Long(24576),
"count" : Long(1)
}
],
"latency" : Long(26845),
"ops" : Long(2)
},
"commands" : {
"histogram" : [ ],
"latency" : Long(0),
"ops" : Long(0)
}
}
}
このページを評価