Last active
August 29, 2015 14:25
-
-
Save mesaque/16aaeac190a3fb8af72a to your computer and use it in GitHub Desktop.
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
| #First you need to active profiling on your mysql | |
| set profiling = 1; | |
| #run some queries and see the status | |
| show profiles; | |
| #after that you cant set the variable and see the query full details | |
| 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