Last active
January 27, 2018 13:12
-
-
Save victorpendleton/82ace7425cd9512bb2756842280056a4 to your computer and use it in GitHub Desktop.
Group active transactions
This file contains 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
SELECT p.user | |
, substring(p.host, 1, IF( (locate(':', p.host)-1)<0, LENGTH(p.host), locate(':', p.host)-1 ) ) as host | |
, Substring(p.info, 1, 56) as snippet | |
, count(*) | |
FROM information_schema.processlist p | |
LEFT OUTER JOIN information_schema.innodb_trx t | |
ON p.id = t.trx_mysql_thread_id | |
WHERE p.command not in ('Binlog Dump GTID', 'Binlog Dump') | |
AND p.user NOT IN ('system user') | |
AND p.id <> connection_id() | |
AND t.trx_started IS NOT NULL | |
GROUP BY 1,2,3 | |
ORDER BY 4 | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment