SELECT
schema_name,
digest_text AS query,
COUNT_STAR AS executions,
SUM_TIMER_WAIT / 1000000000000 AS total_seconds,
AVG_TIMER_WAIT / 1000000000000 AS average_seconds,
MAX_TIMER_WAIT / 1000000000000 AS max_seconds
FROM
performance_schema.events_statements_summary_by_digest
WHERE
schema_name IS NOT NULL
ORDER BY
total_seconds DESC
LIMIT 10;