1、摘要
系统初期使用的是分布式微服务,但是所有业务模型都在同一个数据库实例上,数据库的压力会非常大,这时需要找出系统执行频率比较高的SQL,进行优化。这里重点描述定位问题的方法,使用的数据也都是测试环境数据。
2、统计数据
2.1、统计SQL执行次数
show GLOBAL status like 'Com_insert%';
show GLOBAL status like 'Com_select%';
show GLOBAL status like 'Com_update%';
show GLOBAL status like 'Com_delete%';
选取至少两个时间段的数据
17:57分
Com_insert1609095
Com_select169588912
Com_update69325636
Com_delete980
17:58分
Com_insert1609124
Com_select169631946
Com_update69344475
Com_delete980
18:02分
Com_insert1609421
Com_select169769311
Com_update69403962
Com_delete980
17:57 到17:58 平均每秒的次数
Com_insert0.5次/秒
Com_select717次/秒
Com_update313次/秒
Com_delete0次/秒
17:58 到18:02 平均每秒的次数