SELECT
*,
CONCAT(CONCAT('KILL ', id), ';') AS KILL_SQL,
CONCAT(CONCAT('CALL mysql.rds_kill(', id), ');') AS KILL_SQL_FOR_RDS
FROM
INFORMATION_SCHEMA.PROCESSLIST
WHERE
db = 'your_db'
AND info LIKE '%probrem_query%'
AND user = 'your_user'
AND host LIKE '%your_host%'
AND command LIKE 'Query'
AND time > 10 -- sec
AND id <> CONNECTION_ID()
Last active
February 20, 2024 04:43
-
-
Save bluerabbit/62afd8a3e0f60aac6b4f5f1581102fe3 to your computer and use it in GitHub Desktop.
MySQLでプロセスリストから遅いクエリのセッションをKILLするSQLを生成するSQL
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment