Full Storage Caused by Complex Queries
Scenario
The storage usage of the primary node or read replica is occasionally high or reaches 100%, while the storage usage of other read replicas is within a normal range.
Possible Causes
When you run complex queries on data of a GaussDB(for MySQL) database, GaussDB(for MySQL) creates temporary tables to store the data and operations such as GROUP BY, ORDER BY, DISTINCT, and UNION are executed on the data in the temporary tables. When memory is insufficient, storage space is consumed.
Troubleshooting:
- Check the storage usage of other read replicas. If the storage usage of such read replicas is normal, the high storage usage of the primary node or read replica is related to SQL queries running on it.
- Check the instance slow query logs to find whether any slow-running queries occurred when the storage usage was high.
- If there is a slow-running query, run the explain [slow SQL statement] command to analyze the SQL statement.
- Check whether the extra column in the command output contains using temporary or using filesort. If yes, a temporary table or file is used during the statement execution. If a large amount of data is queried, the storage usage is high.
Solution
- Optimize the query statement by adopting the following measures:
- Add a proper index.
- Use the WHERE condition.
- Rewrite the SQL statement to optimize the execution plan.
- If temporary tables are necessary, reduce the number of concurrent requests.
- Workaround: Scale up storage space temporarily. Optimizing complex query statements cannot reduce the storage usage right away.
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.
For any further questions, feel free to contact us through the chatbot.
Chatbot