Create a gist now

Instantly share code, notes, and snippets.

@xaprb /show_profiles.sql Secret
Created Dec 14, 2013

Converts SHOW PROFILES into a more useful profile table.
SET @query_id = 1;
SELECT STATE, SUM(DURATION) AS Total_R,
ROUND(
100 * SUM(DURATION) /
(SELECT SUM(DURATION)
FROM INFORMATION_SCHEMA.PROFILING
WHERE QUERY_ID = @query_id
), 2) AS Pct_R,
COUNT(*) AS Calls,
SUM(DURATION) / COUNT(*) AS "R/Call"
FROM INFORMATION_SCHEMA.PROFILING
WHERE QUERY_ID = @query_id
GROUP BY STATE
ORDER BY Total_R DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment