Get the App
SLTechnology News&Howtos  ›  Database  › 

How to use pt-kill to kill Big SQL in MySQL

Shulou Source: shulou.com Published: 2022-05-31 15:46:36 10月01日 Update

This article is about how MySQL uses pt-kill to kill big SQL. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Download address

Https://www.percona.com/downloads/percona-toolkit/LATEST/

Decompress pt software

# tar xfz percona-toolkit-3.0.2_x86_64.tar.gz

Install the corresponding perl dependency package

# yum install perl-DBI

# yum install perl-DBD-MySQL

# execute a big SQL

> select * from ls_evaluate

# print out statements that take more than 2 seconds to execute

# bin/pt-kill-uroot-pcnstrong#123454321-S / data/mysql01/mysql.sock-- busy-time 2-- print

# 2018-02-12T11:28:04 KILL 30192 (Query 41 sec) select * from ls_evaluate

# 2018-02-12T11:28:05 KILL 30192 (Query 42 sec) select * from ls_evaluate

# 2018-02-12T11:28:06 KILL 30192 (Query 43 sec) select * from ls_evaluate

# kill statements that have been executed for more than 2 seconds

# bin/pt-kill-uroot-pcnstrong#123454321-S / data/mysql01/mysql.sock-- busy-time 2-- kill

# SQL session disconnected

> select * from ls_evaluate

ERROR 2013 (HY000): Lost connection to MySQL server during query

# kill large queries in the database that take more than 30 seconds to execute every 10 seconds

# bin/pt-kill-uroot-pcnstrong#123454321-S / data/mysql01/mysql.sock-busy-time 30-- kill-- interval 10

Thank you for reading! This is the end of this article on "how MySQL uses pt-kill to kill Big SQL". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: Time content more articles sentences good practical address data database articles look knowledge software reference help related query Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple vpn NVidia Xiaomi MySQL