Docs Menu
Docs Home
/
MongoDB Manual
/ / /

db.collection.configureQueryAnalyzer()

On this page

  • Definition
  • Compatibility
  • Syntax
  • Access Control
  • Behavior
  • Output
  • Examples
  • Learn More
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.

The db.collection.configureQueryAnalyzer() method wraps the configureQueryAnalyzer command.

Returns:A document containing fields describing the old configuration, if one exists, and fields describing the new configuration. For details, see Output.

This method is available in deployments hosted in the following environments:

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

Important

This command is not supported in M0, M2, and M5 clusters. For more information, see Unsupported Commands.

The method has the following syntax:

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

db.collection.configureQueryAnalyzer() has the following fields:

Field
Type
Necessity
Description
mode
string
Required
Mode the query analyzer runs in. Must be set to either "full" or "off".
samplesPerSecond
double
Optional

Number of samples per second.

  • When mode is set to "full", samplesPerSecond must be set between 0 and 50.

  • When mode is set to "off", the server ignores samplesPerSecond.

For details, see samplesPerSeconds Upper Limit.

For details, see configureQueryAnalyzer Access Control.

For behavior, see configureQueryAnalyzer Behavior.

For details, see configureQueryAnalyzer Output.

For examples, see configureQueryAnalyzer Examples.

Back

db.collection.compactStructuredEncryptionData