Home  >  Article  >  Database  >  Mysql checks whether the table is locked

Mysql checks whether the table is locked

anonymity
anonymityOriginal
2019-05-08 17:15:374228browse

Check whether the table is locked:

Execute directly on the mysql command line: show engine innodb status\G.

Check the sql statements that caused the deadlock, analyze the index situation, and then optimize the sql.

Then show processlist to check the sql statements that caused the deadlock to take a long time.

show status like ‘%lock%.

Mysql checks whether the table is locked

Check the table lock status and end the deadlock steps:

1. Check the table lock status

show OPEN TABLES where In_use > 0; This statement records the current lock table status

2. Query process

show processlist Query table locked process

Query the corresponding process kill id

3. Analyze the SQL of the locked table

Analyze the corresponding SQL, add indexes to the table, add indexes to common fields, and add indexes to table related fields

View Things being locked:

SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS.

View things waiting for locks:

SELECT * FROM INFORMATION_SCHEMA. INNODB_LOCK_WAITS.

The above is the detailed content of Mysql checks whether the table is locked. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn