Sample Header Ad - 728x90

Google Cloud SQL (MySQL) consume too much CPU during several days

0 votes
1 answer
317 views
There was noticed that Cloud SQL (MySQL) consumed to much CPU (~100%) during several days. Firstly, I decided that we have many user online or background jobs. But it was regular workload, nothing special. Query Insights showed CPU under 20% for all users in DB and for all DBs in the MySQL instance. Secondly, I decided that we have connections or memory leaks. Also, nothing special. And, lastly, what I checked was output from SHOW FULL PROCESSLIST. I noticed some process which lasts too long (~8days) (see Time field) and State was 'statistics'. This workload was not shown in the CPU chart of Query Insights but belongs to my sql user. And, actually, this is strange for me. The 'Info' field contains a 'SELECT ...' query. I was able to kill such processes. And the CPU came to normal levels. enter image description here enter image description here ## UPDATED: ## 1. https://bugs.mysql.com/bug.php?id=20932 2. https://bugs.mysql.com/bug.php?id=26339 3. https://bugs.mysql.com/bug.php?id=21153 4. https://www.linuxtopia.org/online_books/database_guides/mysql_5.1_database_reference_guide/controlling-optimizer.html ? ### Description ### Looks like, it was combination of two bugs (1) and (2). It seems that the current implementation of search query by tags, with dynamic (depends on amount of selected tags' categories) combination of 'IN ()' clauses where greater than 2 tags and 'INNER JOIN' clauses, leads to performance degradation of MySQL query optimizer. ### Solution (in progress) ### 1. Replace INNER JOIN with INTERSECT (MySQL 8.0.31). 2. Replace IN () with UNION DISTINCT. 3. Add suitable indexes (with help of EXPLAIN ANALYSE).
Asked by Anton Komarov (1 rep)
Feb 24, 2023, 05:37 AM
Last activity: May 4, 2025, 02:04 PM