Database Autonomy Service (DAS) provides the slow query log analysis feature for ApsaraDB RDS for PostgreSQL. You can use this feature to check the trend, execution, and optimization suggestions for slow query logs of your ApsaraDB RDS for PostgreSQL instance.
Prerequisites
Your ApsaraDB RDS for PostgreSQL instance runs ApsaraDB RDS for PostgreSQL High-availability Edition.
Procedure
- Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.
- In the left-side navigation pane, choose .
- On the Slow Log Analysis tab, specify a time range and view the trends, statistics, and details of the slow queries within the specified time range. Note When you specify the time range, the end time must be later than the start time, and the interval between the start time and the end time cannot exceed 24 hours. You can query slow query logs within the latest month.
- You can click a time point in the trend chart and view the statistics and details of the slow queries at the time point.
- Click Export Slow Log to download slow query logs to your computer.
- On the Slow Log Statistics tab, perform the following steps:
- Find the SQL template that you want to view and click Sample in the Actions column. In the Slow Log Sample dialog box, view the details of the slow query logs.
- Find the SQL template that you want to manage and click Optimize in the Actions column. In the SQL Diagnostic Optimization dialog box, view the SQL diagnosis results.
If you accept the SQL diagnosis suggestions, click Copy in the upper-right corner and paste the optimized SQL statements to the database client or Data Management (DMS) for execution. If you do not accept the SQL diagnosis suggestions, click OK.
Note DAS performs SQL diagnostics based on the complexity of SQL statements, the amount of data in the table, and the database load. Suggestions may be returned in more than 20 seconds after the SQL diagnostics are performed. After the diagnostics is complete, the SQL diagnostic engine provides diagnostic results, optimization suggestions, and expected optimization benefits. You can determine whether to accept the suggestions based on the diagnostic results.You can also click Database Expert Service to purchase the expert service. Database Expert Service provides value-added professional database services, such as emergency solutions, health diagnostics, performance optimization, security assurance, and data migration.
- On the Slow Log Details tab, find the SQL template that you want to manage and click Optimize in the Actions column. You can also perform SQL diagnostic optimization on the SQL template.