Skip to content

Instantly share code, notes, and snippets.

@matsuu matsuu/slow_query.sql
Last active Jul 23, 2018

Embed
What would you like to do?
performance_schemaを使用したスロークエリー抽出
-- ORDER BYとLIMITは必要応じて適宜修正
-- VIEWを作成すると便利
SELECT
count_star AS cnt,
sum_timer_wait/1e12 AS sum,
min_timer_wait/1e12 AS min,
avg_timer_wait/1e12 AS avg,
max_timer_wait/1e12 AS max,
sum_rows_sent AS sumRows,
sum_rows_sent/count_star AS avgRows,
schema_name AS db,
digest_text AS query
FROM performance_schema.events_statements_summary_by_digest
ORDER BY sum DESC
LIMIT 10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.