Clean up MySql database

There are things you can think about when deleting data from a large table. In my case the table contains 40 million records.

Symptoms 1: it took long time to execute a delete statement.
Solution: delete smaller chunks of data

Use the following command to find out what are being executed in database

mysql> show processlist;

To see which tables are locked (in used)

mysql> show open tables where in_use > 0;

To kill a process ex. a query that takes long time to execute

mysql> show processlist; 
mysql> kill <pid>;



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: