Analyze Slow Queries
- OAuth 2.0 authentication for programmatic access to Cloud Manager is available as a Preview feature.
- The feature and the corresponding documentation might change at any time during the Preview period. To use OAuth 2.0 authentication, create a service account to use in your requests to the Cloud Manager Public API.
Cloud Manager provides several tools to help analyze slow queries executed on your clusters. See the following sections for descriptions of each tool. To optimize your query performance, review the best practices for query performance.
Performance Advisor
The Performance Advisor monitors slow queries and suggests new indexes to improve query performance.
You can use the Performance Advisor to review the following information:
Query Insights
Monitor collection-level query latency with Query Insights. You can view query latency metrics and statistics for certain hosts and operation types. Manage pinned namespaces and choose up to five namespaces to show in the corresponding query latency charts.
Profiler
The Profiler displays slow-running operations and their key performance statistics. You can explore a sample of historical queries for up to the last 24 hours without additional performance overhead. Before you enable the Profiler, see Considerations.
Best Practices for Query Performance
To optimize query performance, review the following best practices:
Create queries that your current indexes support to reduce the time needed to search for your results.
Avoid creating documents with large array fields that require a lot of processing to search and index.
Optimize your indexes and remove unused or inefficent indexes. Too many indexes can negatively affect write performance.
Consider the suggested indexes from the Performance Advisor with the highest Impact scores and lowest Average Query Targeting scores.
Create the indexes that the Performance Advisor suggests when they align with your Indexing Strategies.
The Performance Advisor can't 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.
Perform rolling index builds to reduce the performance impact of building indexes on replica sets and sharded clusters.
Drop unused, redundant, and hidden indexes to improve write performance and free storage space.