Docs Menu

Docs HomeMongoDB Ops Manager

Configure the Slow Query Threshold

The Performance Advisor recognizes a query as slow if it takes longer to execute than the value of slowOpThresholdMs. By default, this value is 100 milliseconds. You can change the threshold with either the profile command or the db.setProfilingLevel() mongosh method.

Example

The following profile command example sets the threshold at 200 milliseconds:

db.runCommand({
profile: 0,
slowOpThresholdMs: 200
})

If you are running MongoDB 3.6 or later, you can customize the percentage of slow queries in your logs used by the Performance Advisor by specifying the sampleRate parameter.

Example

This sets the slow query threshold to a lower value of 100 milliseconds but also sets the sample rate to 10%.

db.runCommand({
profile: 0,
slowOpThresholdMs: 100,
sampleRate: 0.1
})

Note

By default, the value of profile is 0. MongoDB recommends leaving this value unchanged since other values can negatively impact database performance. To learn more, see the profile command.

←  Monitor and Improve Slow QueriesReview Index Ranking →