Optimize the customer service system database - increase the joint index to solve the problem of abnormally high CPU usage of MySQL

My online customer service system has been running for a year, and recently I found that the CPU usage of MySQL often exceeds 100%

Another time directly caused the server to fail to open, and ssh could not be connected

After searching around, I found that there is a coroutine for timing query, and the sql statement part is not indexed, resulting in slow query, which leads to full CPU

After adding the joint index, the problem is solved, hereby record it

alter table message add KEY `idx_kefuid_mestype_status` (`kefu_id`,`mes_type`,`status`) COMMENT '联合索引';

Guess you like

Origin blog.csdn.net/taoshihan/article/details/131799886