Slow queries degrade database performance and can be difficult to identify without dedicated tooling. ApsaraDB for MongoDB provides slow query log analysis through CloudDBA, giving you four views of your query performance data so you can pinpoint bottlenecks, understand their root causes, and optimize indexes.
Prerequisites
Before you begin, make sure you have:
A replica set instance or a sharded cluster instance
Limits
| Limit | Details |
|---|---|
| Log entry size | 32 KB maximum. Content exceeding this limit is truncated. |
| Query window | Previous month only |
| Time range per query | Maximum 24 hours. The end time must be later than the start time. |
View slow query logs
Go to the ApsaraDB for MongoDB Replica Set Instances page or the ApsaraDB for MongoDB Sharded Cluster Instances page. At the top of the page, select a resource group and a region, then click the ID of the target instance.
In the left navigation pane, click CloudDBA > Slow Query Log Analysis.
Set a time range. The page shows four sections:
Section What it shows When to use it Slow Query Log Trends A trend chart of slow queries over time. Click a point in time to view statistics and details at that moment. Identify when performance degraded Event Distribution Slow query events in the selected time range. Click an event to view its details. Find which events caused spikes Slow Query Log Statistics Aggregated statistics by SQL template. Click Details in the Actions column to view a sample in the Slow Log Sample dialog box. Compare query patterns and prioritize optimization Slow Query Log Details Individual slow query log entries. Inspect specific queries for root cause analysis (Optional) Take additional actions as needed:
If your instance is a sharded cluster, select a node from the Node ID drop-down list to filter slow queries by node.
If an SQL statement is truncated in the view, hover over it to see the full content.
Click
to download the slow query logs to your computer.Click
to load the current parameters into the OpenAPI console for API debugging.
Next steps
After you identify the root cause, take action to improve query performance: