Docs Menu

$listSampledQueries

$listSampledQueries

すべてのコレクションまたは特定のコレクションのサンプル クエリを返します。 サンプリングされたクエリはanalyzeShardKeyコマンドによって使用され、シャードキーの読み取りおよび書込み分散に関するメトリクスを計算します。

$listSampledQueriesの構文は次のとおりです。

{
$listSampledQueries: { namespace: <namespace> }
}
  • 単一のコレクションのサンプリングされたクエリを一覧表示するには、 namespace引数でコレクションを指定します。

  • すべてのコレクションのサンプリングされたクエリを一覧表示するには、 namespace引数を省略します。

$listSampledQueriesにはクラスターでのclusterMonitorロールが必要です。

  • Atlasのマルチテナント構成では$listSampledQueriesは使用できません。

  • スタンドアロン配置では$listSampledQueriesは使用できません。

  • $listSampledQueries--shardsvrレプリカセットに対して直接使用することはできません。 シャーディングされたクラスターで実行する場合、 $listSampledQueriesmongosに対して実行する必要があります。

次の集計操作は、レプリカセット内のすべてのコレクションのすべてのサンプリングされたクエリを一覧表示します。

db.aggregate( [ { $listSampledQueries: { } } ] )

次の集計操作は、 socialデータベース上のpostコレクションのすべてのサンプル クエリを一覧表示します。

db.aggregate( [ { $listSampledQueries: { namespace: "social.post" } } ] )

出力フィールドは、読み取りクエリと書込みクエリで異なります。

{
_id: <uuid>,
ns: "<database>.<collection>",
collectionUuid: <collUUID>,
cmdName: <find|aggregate|count|distinct>,
cmd: {
filter: <object>,
collation: <object>,
let: <object>
},
expireAt: <date>
}
フィールド名
タイプ
説明

_id

UUID

クエリのサンプル ID。

ns

string

サンプリングされたコレクションの名前空間。

collectionUuid

UUID

サンプリングされたコレクションの ID。

cmdName

string

サンプリングされたコマンドの名前。 次のいずれかになります。

  • "find"

  • "aggregate"

  • "count"

  • "distinct"

cmd.filter

オブジェクト

該当する場合は、 で実行されたコマンドをフィルタリングします。

cmd.collation

オブジェクト

該当する場合は、 で実行されたコマンドを照合します。

cmd.let

オブジェクト

コマンドが実行されたカスタム変数(該当する場合)。

expireAt

date

サンプルの有効期限が切れる日付。

{
_id: <uuid>,
ns: "<database>.<collection>",
collectionUuid: <collUUID>,
cmdName: <update|delete|findAndModify>,
cmd: <object>,
expireAt: <date>
}
フィールド名
タイプ
説明

_id

UUID

クエリのサンプル ID。

ns

string

サンプリングされたコレクションの名前空間。

collectionUuid

UUID

サンプリングされたコレクションの ID。

cmdName

string

サンプリングされたコマンドの名前。 次のいずれかになります。

  • "update"

  • "delete"

  • "findAndModify"

cmd

オブジェクト

コマンド オブジェクト

expireAt

date

サンプルの有効期限が切れる日付。