Created
January 22, 2016 16:44
-
-
Save sqlstunts/2e3a53f5adea4429f3e4 to your computer and use it in GitHub Desktop.
Get live queries from MySQL instance in real time.
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
SELECT | |
plist.id, plist.user, plist.host, plist.db, | |
plist.command, plist.TIME, plist.state, | |
plist.info, trx.trx_state, | |
trx.trx_wait_started, | |
trx.trx_query, blockerw.blocking_trx_id, | |
(CASE | |
WHEN (blockerw.blocking_trx_id IS NOT NULL) THEN 'Blocked' | |
WHEN (lockedtr.trx_id IS NOT NULL) THEN 'Locked' | |
ELSE '' | |
END) is_blocker | |
FROM | |
information_schema.PROCESSLIST AS plist | |
LEFT OUTER JOIN | |
information_schema.innodb_trx AS trx ON trx.Trx_MySQL_Thread_ID = plist.id | |
LEFT OUTER JOIN | |
information_schema.innodb_lock_waits blockerw ON blockerw.blocking_trx_id = trx.trx_id | |
LEFT OUTER JOIN | |
information_schema.innodb_lock_waits lockedw ON lockedw.requesting_trx_id = trx.trx_id | |
LEFT OUTER JOIN | |
information_schema.innodb_trx lockedtr ON lockedtr.trx_id = lockedw.blocking_trx_id | |
where plist.command NOT IN ('Sleep', 'Binlog Dump') | |
ORDER BY time DESC | |
LIMIT 10; | |
SELECT id, user, host, db, command, time, state, info | |
FROM information_schema.processlist | |
WHERE command NOT IN ('Sleep', 'Binlog Dump') | |
ORDER BY time ASC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment