How can I show mysql locks?

See Marko’s link for InnoDB tables and the caveats.

For MyISAM, there isn’t a dead easy “this is the offending query” solution. You should always start with a processlist. But be sure to include the full keyword so that the printed queries aren’t truncated:

SHOW FULL PROCESSLIST;

This will show you a list of all current processes, their SQL query and state. Now usually if a single query is causing many others to lock then it should be easy to identify. The affected queries will have a status of Locked and the offending query will be sitting out by itself, possibly waiting for something intensive, like a temporary table.

If it’s not obvious then you will have to use your powers of SQL deduction to determine which piece of offending SQL may be the cause of your woes.

Leave a Comment

error code: 523