Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the principle of Mysql lock mechanism?

2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what is the principle of Mysql lock mechanism". In daily operation, I believe many people have doubts about what is the principle of Mysql lock mechanism. Xiaobian consulted all kinds of information and sorted out simple and easy operation methods. I hope to help you answer the doubts of "what is the principle of Mysql lock mechanism"! Next, please follow the small series to learn together!

I. Locking mechanisms of different storage engines

Mysql has multiple storage engines, and the locking mechanisms of different storage engines are different;

2. Locking mechanism of InnoDB

InnoDB contains two types of locks: row locks and table locks.

1. When updating data, if there is an index in the where condition, it is a row lock, otherwise it is a table lock;

2. InnoDB row locks have both pessimistic locks and optimistic locks.

Optimistic lock: By default, update sql we write is optimistic lock, that is, only when the update operation is submitted, it will detect whether the version of the row has changed, and update if there is no change (MVCC mechanism).

Pessimal lock: such as select * from table where id = '1001' for update, this is a pessimistic lock, other transactions can not be updated.

At this point, the study of "What is the principle of Mysql lock mechanism" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 239

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report