You can view and analyze the slow logs generated during database operations in the TencentDB for MongoDB console for targeted database performance optimization.
- Slow logs are often used as the basis for optimizing business operations in MongoDB. For more information, see Database Profiler.
- The system provides two query methods as described below:
- Query statistics: slow logs for the specified time period are queried, and the query results are aggregated and analyzed by command (operation) type.
- Query details: a specific operation command is specified to query slow logs, and the query results are displayed in a list displaying the execution durations and log details.
Currently, TencentDB for MongoDB 4.2, 4.0, 3.6, and 3.2 support slow log management.
- The system logs operations with an execution time of more than 100 ms.
- The slow logs are retained for 7 days. The time span for a single query cannot exceed 1 day.
- Only the first 10,000 slow logs can be queried. If the query is slow, you can narrow down the query time period.
Querying slow log
- Log in to the TencentDB for MongoDB console.
- In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Instance. The directions for the two types of instances are similar.
- Above the instance list on the right, select the region.
- In the instance list, find the target instance.
- Click the target instance ID to enter the Instance Details page.
- Select the Database Management > Slow Log Query tab.
- On the Slow Log Query tab, select a query method to query slow logs.
- Query statistics: select a query time period, set the time consumed threshold, and click Query.
- Query details:
- Select the specific executed command to be queried in Executed Command.
- Select a query time period, set the time consumed threshold, and click Query.
- View and analyze the slow logs.
- A statistics query result contains four fields:
- Query Method: statistics query.
- Sample Command: output statements aggregated in the command type dimension. You mainly need to refer to the command when troubleshooting problems.
- Average Execution Time (ms): average execution time (in ms) of operations aggregated in the command type dimension.
- Total: total occurrences of operations aggregated in the command type dimension.
- A details query result contains three fields:
- Query Method: details query.
- Time Consumed: execution time of the business command (in ms).
- Log Details: details of the business command.
Slow log management
Viewing slow log request statement
- On the Slow Query Management page, you can view the slow log request statements.
- In the search box in the top-right corner, enter the information to be queried for search.
|Query Statement||Query statement.|
|Op Type||Operation type.|
|Node Location||Node of the executed operation.|
|Namespace||Namespace of the database table.|
|Executed Time||Time consumed.|
|Details||Details of the executed statement.|
- On the Slow Query Management page, select the slow log request statements to be cleared.
- Click Batch Kill above the list.
- In the Note pop-up window, read the prompt carefully.
- Click OK.
Downloading slow log file
- On the Slow Log Download List page, you can view current slow log files.
- Find the file to be downloaded and click Download in the Operation column.