Understanding mysql locks (1) Overview of locks compared with other databases, MySQL locks are relatively simple. The most notable feature is that different memory engines support different locks, however, mysql memory engines use three types of locking mechanisms: row locking, table locking, and table locking. MyISAM mainly uses table-level locking, while Innodb uses row locking. ① Table locking: a small number of locks are opened, and locks are fast. No deadlocks are generated. The lock granularity is large, with the highest probability of lock conflicts and the lowest concurrency. Www.2cto.com
(2) rows of locks: the locks are too large to be opened, and the locks are slow. Deadlocks may occur. The minimum lock granularity, the lowest probability of lock conflicts, and the highest concurrency.
③ Locking locks: The time for unlocking and locking is between the table lock and the row lock. A deadlock occurs. The lock granularity is between the table lock and the row lock, concurrency is average. Each lock is designed based on its own application scenarios. Table locks may be suitable for web applications, while row-level locks may be more suitable for OLTP systems.