Docs Menu
Docs Home
/
MongoDB Atlas
/ /

Monitor Query Performance

On this page

  • Considerations
  • Required Access
  • Enable and Disable the Query Profiler
  • Access the Query Profiler

Only available on M10+ clusters and Serverless instances

The Query Profiler diagnoses and monitors performance issues. This monitoring can expose slow-running queries and their key performance statistics in the Atlas UI.

Atlas collects and displays statistics from any of your mongod instances. The Query Profiler identifies slow queries based on log data from your mongod instances. Atlas displays this data on the Query Insights tab in the Query Profiler section of an instance.

Note

The Query Profiler differs from the Database Profiler. The Query Profiler identifies specific inefficient queries based on entries from your mongod logs. The Database Profiler returns detailed information about commands executed on the mongod based on the specified profiling level. Changing the profiling level doesn't impact the slow queries displayed in the Query Profiler.

The Atlas Query Profiler shows operations across your entire cluster by default. You can select to view operations from a specific shard or nodes within a shard using the Host Selector dropdown. The Query Insights tab displays information to reveal slow database operations over a set time frame, such as the following:

  • Operation Execution Time

  • Server Execution Time (Serverless instances)

It displays this data in both a chart and a table that each can filter on aspect and time frame.

The Atlas Query Profiler supports binning operations of the same type running on the same collection around the same timestamp in order to support additional datapoints.

In order to support additional datapoints, the Atlas Query Profiler supports binning operations that meet the following critera:

  • The operations are of the same operation type.

  • The operations are running on the same namespace.

  • The operations have matching hasSort and usedIndex boolean values.

  • The operations are executed around the same timestamp.

Atlas manages the threshold for slow operations for each mongod host based on average operation execution time on that host. This threshold can be changed using the db.setProfilingLevel mongosh command.

Note

Changing the threshold for slow operations using db.setProfilingLevel can impact performance and system log settings. Carefully consider any performance and security implications before you use db.setProfilingLevel to adjust the Query Profiler settings on a production deployment. Query Profiler settings reset to default values following a node restart.

Additionally, zooming in on the x axis of the scatterplot will refetch slow operations and may provide more detailed fidelity of slow operations during the selected timeframe.

Note

To opt out of the Atlas-managed slow operation threshold and use a fixed slow query threshold of 100 milliseconds instead, use the Atlas Administration API. See Disable Managed Slow Operation Threshold. For M0, M2, M5 clusters and Serverless instances, Atlas disables the Atlas-managed slow query operation threshold by default and you can't enable it.

Important

Please read the following considerations before you enable the Query Profiler.

Profile data may include sensitive information including the content of database queries. Ensure that exposing this data to Atlas is consistent with your information security practices.

The Query Profiler displays approximately 100,000 sampled logs at a time. It shows all the logs if 100,000 or less logs were recorded in the selected hosts and time range.

Atlas displays no more than 100,000 data points in the Query Profiler charts.

Log data is processed in batches. Data can be delayed up to five minutes from realtime.

If a cluster experiences an activity spike and generates an extremely large quantity of log messages, Atlas may stop collecting and storing new logs for a period of time.

Note

Log analysis rate limits apply only to the Performance Advisor UI, the Query Insights UI, the Access Tracking UI, and the Atlas Search Query Analytics UI. Downloadable log files are always complete.

To enable or disable Performance Advisor and the Query Profiler for a project, you must have the Project Owner role for the project or the Organization Owner role on its parent organization.

Atlas enables the Query Profiler by default.

To disable the Query Profiler:

1
  1. If it's not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.

  2. If it's not already displayed, select your desired project from the Projects menu in the navigation bar.

  3. Next to the Projects menu, expand the Options menu, then click Project Settings.

    The Project Settings page displays.

2

In the Database Monitoring Tools section, toggle Performance Advisor and Profiler to Off.

To access the Query Profiler:

  • For a cluster:

    1. Click View Monitoring for that instance in the project panel.

    2. Click the Query Insights tab.

    3. Click the Query Profiler tab.

    Note

    When you access the Query Profiler at the cluster level, the Query Profiler displays the all your data from the log on the primary and secondary nodes.

  • For a Serverless instance, click the Monitoring tab.

Above the chart, select the metric and time period you want to see.

  1. Select the metric from the Display menu. Atlas accepts:

    • Default: Operation Execution Time or Server Execution Time (Serverless instances)

    • Keys Examined

    • Docs Returned

    • Examined:Returned Ratio

    • Num Yields

    • Response Length

  2. Select the time period from the View Last menu. Atlas accepts:

    • 5 days

    • 24 hr (default)

    • 12 hr

    • 8 hr

    • 1 hr

    • 10 min

To view a full query and its execution statistics, click on the point representing it on the chart. You can also click and drag along the x and y axes to zoom in on a specific subset of collected data. Viewing more details on a binned group of operations selects a random operation from the group. You must zoom in to view details about a particular operation within a binned group of operations.

Above the table, select the namespace, operation type, and metric you wish to profile:

  1. Click All Namespaces to change which combination of databases and collections to profile.

  2. Click All Operations to change which operations you want to profile.

  3. Click Operation Execution Time or Server Execution Time (Serverless instances) to change which metric you want to profile. Atlas accepts:

    • Default: Operation Execution Time or Server Execution Time (Serverless instances)

    • Keys Examined

    • Docs Returned

    • Examined:Returned Ratio

    • Num Yields

    • Response Length

Back

Query Latency