$listSampledQueries
On this page本页内容
Definition定义
Syntax语法
$listSampledQueries
has this syntax:具有以下语法:
{
$listSampledQueries: { namespace: <namespace> }
}
Behavior行为
To list sampled queries for a single collection, specify the collection in the若要列出单个集合的采样查询,请在namespace
argument.namespace
参数中指定集合。To list sampled queries for all collections, omit the若要列出所有集合的采样查询,请省略namespace
argument.namespace
参数。
Access Control访问控制
$listSampledQueries
requires the 需要群集上的clusterMonitor
role on the cluster.clusterMonitor
角色。
Limitations局限性
You cannot use不能在Atlas多租户配置上使用$listSampledQueries
on Atlas multitenant configurations.$listSampledQueries
。You cannot use不能在独立部署上使用$listSampledQueries
on standalone deployments.$listSampledQueries
。You cannot use不能直接对$listSampledQueries
directly against a--shardsvr
replica set. When running on a sharded cluster,$listSampledQueries
must run against amongos
.--shardsvr
副本集使用$listSampledQueries
。在分片集群上运行时,$listSampledQueries
必须针对mongos
运行。
Examples实例
List Sampled Queries for All Collections列出所有集合的采样查询
The following aggregation operation lists all sampled queries for all collections in the replica set:以下聚合操作列出了副本集中所有集合的所有采样查询:
db.aggregate( [ { $listSampledQueries: { } } ] )
List Sampled Queries for A Specific Collection列出特定集合的采样查询
The following aggregation operation lists all sampled queries for a 以下聚合操作列出了post
collections on the social
database:social
数据库上post
集合的所有采样查询:
db.aggregate( [ { $listSampledQueries: { namespace: "social.post" } } ] )
Output输出
The output fields differ for read and write queries.读查询和写查询的输出字段不同。
Read Queries读取查询
{
_id: <uuid>,
ns: "<database>.<collection>",
collectionUuid: <collUUID>,
cmdName: <find|aggregate|count|distinct>,
cmd: {
filter: <object>,
collation: <object>,
let: <object>
},
expireAt: <date>
}
_id | UUID | |
ns | string | |
collectionUuid | UUID | |
cmdName | string |
|
cmd.filter | object | |
cmd.collation | object | |
cmd.let | object | |
expireAt | date |
Write Queries写入查询
{
_id: <uuid>,
ns: "<database>.<collection>",
collectionUuid: <collUUID>,
cmdName: <update|delete|findAndModify>,
cmd: <object>,
expireAt: <date>
}
_id | UUID | |
ns | string | |
collectionUuid | UUID | |
cmdName | string |
|
cmd | object | |
expireAt | date |