Skip to content

Commit ef4ca59

Browse files
authored
Update MySQL query to filter by execution time
Filter process list to show only long-running queries.
1 parent 961bb7e commit ef4ca59

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

content/docs/cheatsheets/mysql.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ SELECT
2222
pl.INFO AS "text"
2323
FROM information_schema.PROCESSLIST AS pl
2424
LEFT OUTER JOIN information_schema.INNODB_TRX AS trx ON pl.ID = trx.trx_mysql_thread_id
25-
WHERE pl.COMMAND NOT IN ('Sleep', 'Connect', 'Binlog Dump')
25+
WHERE
26+
pl.COMMAND NOT IN ('Sleep', 'Connect', 'Binlog Dump')
27+
AND pl.TIME > 1200
28+
AND pl.COMMAND = 'Query'
29+
AND pl.STATE = 'executing'
2630
ORDER BY pl.TIME DESC;
2731
```
2832

0 commit comments

Comments
 (0)