Skip to content

Instantly share code, notes, and snippets.

@victorpendleton
Last active January 27, 2018 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victorpendleton/82ace7425cd9512bb2756842280056a4 to your computer and use it in GitHub Desktop.
Save victorpendleton/82ace7425cd9512bb2756842280056a4 to your computer and use it in GitHub Desktop.
Group active transactions
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