How to kill long run mysql queries

As a Database Administrator you should be aware about the slow queries .  When you are running a high traffic website with multiple mysql servers , you have to be very careful about long running queries, ideally all queries should get executed below 2 seconds for high traffic site as there are thousands of database queries are coming to the mysql read servers. If one query get locked in MyISAM then the subsequent all the queries will get locked and finally your site will collapse.

The slow query log consists of all SQL statements that took more than long_query_time seconds to execute and required at least min_examined_row_limit rows to be examined. The time to acquire the initial table locks is not counted as execution time. mysqld writes a statement to the slow query log after it has been executed and after all locks have been released, so log order might be different from execution order.

The best way to handle this situation is using a third party tool called mkill (Twitter is using this utility to kill long running queries.)

Read more here to use mkill  How to Install and Configure mkill – Kills slow queries



Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>