For locks, you need to focus on the following:
1. Lock classification
● Table locks
● Row locks
● Object locks (meta-table locks), implemented at the table cache layer
● Page locks
● Exclusive locks (mutexes, X locks)
● Shared locks ( S lock)
2. Precautions for the use of locks
● The innodb engine is a row-level lock, which is suitable for the background system of high concurrency scenarios
● The myisam engine uses a table-level lock, which is suitable for the front-end web system
● When delete\update is executed, it will be added by default Mutual exclusion lock
● innodb, if delete \update is not indexed in the field after the where condition, it will cause a lock table and serious concurrency performance
● When modifying fields, deleting primary key, and deleting primary key fields will cause meta-table locks
Set lock waiting timeout : innodb_lock_wait_timeout=500 (unit: s)
Commonly used commands for locks:
● View table lock contention
show status like 'table%'
The higher the value is, the more serious the lock contention is.
● Check the status of the lock table
show processlist;
the corresponding status value can see whether there is a lock table.
Understand the concept of mysql_lock
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326175234&siteId=291194637
Ranking