Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save toriaezunama/e0287201a2ea5703937c97251f0ba28d to your computer and use it in GitHub Desktop.
Save toriaezunama/e0287201a2ea5703937c97251f0ba28d to your computer and use it in GitHub Desktop.
10 slow queries by average time taken to execute the query
select SCHEMA_NAME,
DIGEST,
DIGEST_TEXT,
FORMAT(COUNT_STAR, 0) as COUNT_STAR,
CONCAT(ROUND(SUM_TIMER_WAIT * 0.000000000001, 2), 's') as SUM_TIMER_WAIT_S,
CONCAT(ROUND(MIN_TIMER_WAIT * 0.000000001, 2), 'ms') as MIN_TIMER_WAIT_MS,
CONCAT(ROUND(AVG_TIMER_WAIT * 0.000000000001, 2), 's') as AVG_TIMER_WAIT_S,
CONCAT(ROUND(MAX_TIMER_WAIT * 0.000000001, 2), 'ms') as MAX_TIMER_WAIT_MS,
CONCAT(ROUND(SUM_LOCK_TIME * 0.000000000001, 2), 's') as SUM_LOCK_TIME_S
from events_statements_summary_by_digest
order by AVG_TIMER_WAIT desc
limit 10\G
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment