MySQL – Debugging QPS

myisamMySQL

I see 5 Kqps on my DB server during 5 mins interval on zabbix dashboard. But sum of all max queries(Delete/select/Insert/Update/Replace) during that interval come out to be 1300.
Not sure how come max 5kqps is displaying but sum of all max is 1300 ? My objective is to find which specific DML(insert/update/select/delete) is causing high QPS here and get some direction from here ? Another point is to understand is there anything else that can cause high QPS apart from these DML so that I can move in right direction. I am bit confused how come Max QPS can be some of individual DML QPS or I am missing anything here ?

Also IOPS during that shows 1Kops, if each query is is even hitting disk, shouldn't it be close to 5Kops ? Where can be the gap ?

Best Answer

SHOW GLOBAL STATUS before and after a test run. Then look at the differences in Com_..., Questions, and Queries.

Things like Com_insert will tell you specifically how many INSERTs there were.

If you have Stored routines, Questions and Queries will not be the same, the difference being due to one counting statements in the routines; the other not.

IOPs may have very little relation to qps. One SELECT could cause millions of IOPs if it is scanning a huge table that is not cached in RAM. OTOH, a thousand simple SELECTs where all the necessary data is cached might cause zero IOPs.

QPS is not as important as the sum of the times for all the queries. In the previous paragraph, that one big query arguably might have more impact on the system than the thousand small ones.

To find which statements are being naughty, use the slowlog. It will catch DDLs and DMLs. See http://mysql.rjweb.org/doc.php/mysql_analysis#slow_queries_and_slowlog