MySQL Lock overview

Source: Internet
Author: User

Compared with other databases, the lock mechanism of MySQL is relatively simple, the most notable feature of the base is that different storage engines support different locking mechanisms. For example, the MyISAM and memory storage engines use a table-level lock (table-level locking); The BDB Storage engine uses page locks (page-level locking), but also supports table-level locks; The InnoDB storage engine supports both row-level and technical table-level locks, but row-level locks are used by default.

MySQL features of these 3 types of locks can be broadly summarized as follows:

Table-level Lock: Low overhead, lock fast, no deadlock, lock granularity, lock conflict is the highest probability, concurrency is the lowest.

Row-level locks: overhead, locking slow, deadlock, minimum lock granularity, the lowest probability of lock collisions, and highest concurrency.

Page locks: overhead and reselling time bounds between table and row locks, deadlock occurs, lock granularity bounds between table and row locks, and concurrency is common.

You can analyze table lock contention on the system by examining the table_locks_waited and table_locks_immediate state variables:

If the value of table_locks_waited is high, there is a serious emergency case for table-level locks.

MySQL Lock overview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.