在MySQL中查找长时间运行的查询

sql
阅读 36 收藏 0 点赞 0 评论 0

query_killer.sh
host="octopus-read-1"
password=XXXXXXX
client="mysql -uhousetrip -p${password} --ssl-ca=/var/www/housetrip/shared/config/mysql-ssl-ca-cert.pem -h ${host}.cjumddpb9pgp.eu-west-1.rds.amazonaws.com housetrip_production"
query="SELECT id
  FROM information_schema.processlist
  WHERE command <> 'Sleep'
  AND info NOT LIKE '%PROCESSLIST%'
  AND command <> 'Killed'
  AND info LIKE '%EXPLAIN'"

$client -e "${query}" | \
sed -e 's/[^0-9]//g; s/^/kill /; s/$/;/' | {
  while read LINE ; do
    echo "$LINE"
    echo "$LINE" | $client
  done
}
query_finder.sql
SELECT id,state,command,time,left(replace(info,'\n','<lf>'),120)
FROM information_schema.processlist
WHERE command <> 'Sleep' 
AND info NOT LIKE '%PROCESSLIST%'
ORDER BY time DESC LIMIT 50;
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号