Navigation
This version of the documentation is archived and no longer supported. It will be removed on EOL_DATE. To learn how to upgrade your version of MongoDB Ops Manager, refer to the upgrade documentation.
You were redirected from a different version of the documentation. Click here to go back.
This version of the manual is no longer supported. It will be removed on EOL_DATE.

Performance Advisor

The Performance Advisor monitors any operation with a query predicate that MongoDB considers slow and suggests new indexes to improve query performance. For the selected host and time period, the Performance Advisor evaluates up to the 20,000 most recent slow queries found in the logs.

Recommended indexes are accompanied by sample queries, grouped by query shape, that were run against a collection that would benefit from the suggested index. The Performance Advisor is always enabled and does not negatively affect the performance of your Ops Manager clusters.

Note

You must meet the following requirements to view the Performance Advisor:

  • Run MongoDB version 3.2+ on your cluster
  • Use Automation Agent version 4.5.7+ to manage your cluster

See Install or Update the Automation Agent for upgrade instructions for the Automation Agent.

In addition, to view the field values in the example queries, you must be a user with at least one of the following access:

Users without the aforementioned access cannot see the field values.

Considerations

Indexes improve read performance, but a large number of indexes can negatively impact write performance since indexes must be updated during writes. It is important to consider this tradeoff when deciding whether to create new indexes for a collection. Examine whether a query for such a collection can be modified to take advantage of existing indexes, as well as whether a query occurs often enough to justify the cost of a new index.

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() mongo shell method. For 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+, you can customize the percentage of slow queries in your logs used by the Performance Advisor by specifying the sampleRate parameter. The following example 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. See the profile command for more information.

Understanding the Query Inefficiency Score

The Performance Advisor displays sample queries with recommended indexes. Each sample query includes a query inefficiency score, which is how many documents were read for every document returned by the query. A score of 1 represents a very efficient query because every document read matched the query and was returned with the query results. The Performance Advisor displays a warning icon next to any score over 1,000, which represent highly inefficient queries. All suggested indexes represent an opportunity to improve query performance.

Limitation

The Performance Advisor cannot suggest indexes for MongoDB databases configured to use the ctime timestamp format. As a workaround, set the timestamp format for such databases to either iso8601-utc or iso8601-local.

Procedure

To access the Performance Advisor:

1

Click Deployment.

2

Click the replica set where the collection resides.

If the replica set resides in a sharded cluster, first click the sharded cluster containing the replica set.

3

Click Performance Advisor.

4

Select a collection from TOP COLLECTIONS.

5

Select the time period from the list box for which you want to view data.

The Performance Advisor displays up to 20 query shapes across all collections in the cluster and suggested indexes for those shapes.

Note

The Performance Advisor collects existing indexes for collections with slow queries every 12 hours. However, the Performance Advisor generates suggested indexes based on actual queries within five minutes of query execution. It is possible to see suggestions for indexes that you have already created, but these are removed the next time that the Performance Advisor collects indexes.