Skip to content

Instantly share code, notes, and snippets.

@ronaldbradford
Last active April 22, 2024 19:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronaldbradford/219aa350000472711af18ad572e90661 to your computer and use it in GitHub Desktop.
Save ronaldbradford/219aa350000472711af18ad572e90661 to your computer and use it in GitHub Desktop.
A summary of incoming MySQL Connections
SELECT /* Host connections */ SUBSTRING_INDEX(host, ':', 1) AS host, user, COUNT(*) AS host_connections
FROM information_schema.processlist
GROUP BY SUBSTRING_INDEX(host, ':', 1), user;
SELECT /* Running connections per source/user/schema */ host,user,db,command,COUNT(*) AS running
FROM information_schema.processlist
WHERE command NOT IN ('Sleep','Daemon','Binlog Dump')
GROUP BY host, user;
SELECT /* thread counts */ variable_name, variable_value
FROM performance_schema.global_status
WHERE variable_name LIKE 'thread_%';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment