Database Manual / Reference / mongosh Methods / Collections

db.collection.configureQueryAnalyzer() (mongosh method方法)

Definition定义

db.collection.configureQueryAnalyzer(options)

Configures query sampling for a collection on a replica set or sharded cluster. Sampled queries provide information to analyzeShardKey to calculate metrics about read and write distribution of a shard key.为副本集或分片群集上的集合配置查询采样。采样查询为analyzeShardKey提供信息,以计算分片键的读写分布指标。

The db.collection.configureQueryAnalyzer() method wraps the configureQueryAnalyzer command.db.collection.configureQueryAnalyzer()方法封装了configureQueryAnalyzer命令。

Returns:返回A document containing fields describing the old configuration, if one exists, and fields describing the new configuration. For details, see Output.包含描述旧配置的字段(如果存在)和描述新配置的字段的文档。有关详细信息,请参阅输出

Compatibility兼容性

This method is available in deployments hosted in the following environments:此方法在以下环境中托管的部署中可用:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud:云中MongoDB部署的完全托管服务

Important

This command is not supported in M0 and Flex clusters. For more information, see Unsupported Commands.M0和Flex集群不支持此命令。有关详细信息,请参阅不支持的命令

  • MongoDB Enterprise: The subscription-based, self-managed version of MongoDB:MongoDB的基于订阅的自我管理版本
  • MongoDB Community: The source-available, free-to-use, and self-managed version of MongoDB:MongoDB的源代码可用、免费使用和自我管理版本

Syntax语法

The method has the following syntax:该方法具有以下语法:

db.collection.configureQueryAnalyzer(
{
mode: <string>,
samplesPerSecond: <double>
}
)

Fields字段

db.collection.configureQueryAnalyzer() has the following fields:具有以下字段:

Field字段Type类型Necessity必要性Description描述
modestring字符串Required必需Mode the query analyzer runs in. Must be set to either "full" or "off".查询分析器运行的模式。必须设置为"full""off"
samplesPerSeconddouble双精度浮点数Optional可选

Number of samples per second.每秒采样数。

  • When mode is set to "full", samplesPerSecond must be set between 0 and 50.mode设置为"full"时,samplesPerSecond必须设置在050之间。
  • When mode is set to "off", the server ignores samplesPerSecond.mode设置为"off"时,服务器忽略samplesPerSecond

For details, see samplesPerSeconds Upper Limit.有关详细信息,请参阅samplesPerSeconds上限

Access Control访问控制

For details, see configureQueryAnalyzer Access Control.有关详细信息,请参阅configureQueryAnalyzer访问控制

Behavior行为

For behavior, see configureQueryAnalyzer Behavior.有关行为,请参阅configureQueryAnalyzer行为

Output输出

For details, see configureQueryAnalyzer Output.有关详细信息,请参阅configureQueryAnalyzer输出

Examples示例

For examples, see configureQueryAnalyzer Examples.有关示例,请参阅configureQueryAnalyzer示例

Learn More了解更多