Created
June 22, 2018 16:06
-
-
Save gugu/bbc0e45c92801a6abc29f1e6784dce42 to your computer and use it in GitHub Desktop.
Slow log UI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT q, COUNT(*) AS c, avg(query_time) as avg_query, avg(lock_time), COUNT(*) * AVG(query_time) as total_time | |
FROM ( | |
SELECT regexp_replace(regexp_replace(regexp_replace(sql_text, "'.*?'", '?'), 'IN \\(.*?\\)', 'IN ?'), '\\d+', '?') as q, query_time, lock_time from mysql.slow_log | |
WHERE DATEDIFF(start_time, NOW()) < 30 | |
) a | |
GROUP by q | |
ORDER BY total_time DESC | |
LIMIT 10; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment