Help Center/
Data Admin Service/
Best Practices/
How Do I Check and Optimize Tables by Checking Top SQL?
Updated on 2024-10-28 GMT+08:00
How Do I Check and Optimize Tables by Checking Top SQL?
Example Problem
A user found in the exported logs that it took more than 2s for a SELECT statement to query information of table test and the lock wait duration was long.
Suggestion
- Add indexes.
- Optimize tables
Procedure
- Log in to the DAS console.
- Click in the upper left corner and select a region and project.
- Click in the upper left corner, and under Databases, click Data Admin Service.
- In the navigation pane, choose Intelligent O&M > Instance List.
Alternatively, on the Overview page, click Go to Intelligent O&M.
- In the upper right corner of the instance list, filter instances by engine, name, or IP address. Click Details.
Figure 1 Intelligent O&M instance overview page
- On the displayed page, click the SQL tab and then TOP SQL.
Figure 2 TOP SQL
- On the TOP SQL tab page, click View Details to view template information of SELECT and find the database in which SELECT was executed for longer than 2s.
Figure 3 SQL statements
- Log in to the target instance on the Development Tool page and choose Database Management. Select the database found in 7. Choose Tables in the navigation pane on the left, locate the table that you want to view, and click View in the Operation column. View the index length and row count in the table.
Figure 4 Viewing table details
- (Example) If there are few indexes, click Alter and add indexes. Return to the Tables tab and click Query SQL Statements.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot