Docs Home → Launch & Manage MongoDB → MongoDB Atlas
Monitor Query Performance
On this page
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. You can explore a sample of historical queries for up to the last 5 days without additional cost or performance overhead.
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.
From one or more of your hosts, the Query Insights displays an aspect such as the following to reveal slow database operations over a set time frame:
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.
Tip
You can use $comment
to add descriptive information
that will appear in the Query Profiler to the query predicate.
This information makes it easier to analyze your Query Profiler data.
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.
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.
Considerations
Important
Please read the following considerations before you enable the Query Profiler.
Security
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.
Data Analysis Limitations
The Query Profiler displays up to 10,000 of the most recent operations, or 10MB of the most recent logs. Then, the Query Profiler won't display new operations for 5 days.
Data Display Limitations
Atlas displays no more than 10,000 data points in the Query Profiler charts.
Log data is processed in batches. Data can be delayed up to five minutes from realtime.
Log Quantity
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.
Required Access
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.
Enable and Disable the Query Profiler
Atlas enables the Query Profiler by default.
To disable the Query Profiler:
Next to the Projects menu, expand the Options menu.
Click Project Settings.
In the Database Monitoring Tools section, toggle Performance Advisor and Profiler to Off.
Access the Query Profiler
To access the Query Profiler:
For a cluster:
Click View Monitoring for that instance in the project panel.
Click the Query Insights tab.
Click the Query Profiler tab.
For a serverless instance, click the Monitoring tab.
Query Profiler Chart
Above the chart, select the metric and time period you want to see.
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
Select the time period from the View Last menu. Atlas accepts:
24 hr (default)
12 hr
6 hr
1 hr
15 min
To view a full query and its execution statistics, click on the point representing it on the chart.
Query Profiler Table
Above the table, select the namespace, operation type, and metric you wish to profile:
Click All Namespaces to change which combination of databases and collections to profile.
Click All Operations to change which operations you want to profile.
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