Relational Database Service (MySQL)

High CPU Caused by Full Table Scanning

2024-06-25 01:26:58

Scenario Description

The MySQLd CPU overhead is 100%.

Possible Causes

1. Through the top query, it is determined that the high CPU is occupied by MySQL processes, and the effect of other processes in the host is eliminated.

 

2. View the processlist. Although without obvious AP queries, the select count (1) concurrency is high.

 

3. Run explain secondql to check the execution plan. It was found that the SQL adopted the full table scan.

 

Solution

This SQL statement has a where uuid=$x query. To avoid a full table scan, you can index the UUID.

 

The CPU overhead is 200% before indexing the UUID shown in the figure above.

sql: alter table t_xx_picture add index idx_uuid(uuid);

 

After indexing the UUID in the figure above, the CPU overhead is reduced from 200% to 22.9%.


aZlxdvjWPCwP