In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The following mainly brings you the necessity and categories of locks in MySQL. I hope these contents can bring you practical use, which is also the main purpose of my article on the necessity and categories of locks in MySQL. All right, don't talk too much nonsense, let's just read the following.
When the number of user visits increases, the database is often a performance bottleneck of the system, but not only the performance bottleneck, but also data security will emerge, at this time the locking mechanism is very necessary.
The data security problems caused by concurrency are mainly divided into three aspects: dirty reading, phantom reading and unrepeatable reading.
one。 Dirty reading
Dirty reading is when one transaction reads uncommitted data from another transaction.
Timeline transaction 1 transaction 2 1 begin; 2 select * from lock where id = 1; 3 begin; 4 update lock set name='dirty'; 6 select * from lock where id = 1; 7 commit Commit
two。 Illusory reading
Phantom reading is when one transaction reads the data of another transaction insert
Timeline transaction 1 transaction 2 1 begin; 2 select * from lock where id > 1; 3 begin; 4 insert lock select 2; 5 commit 6 select * from lock where id > 1; 7 commit
three。 Non-repeatable
Non-repeatable reading means that the results returned from multiple readings of unified data are inconsistent. Unlike dirty reading, this is reading data that has been submitted; unlike phantom reading, this is updated data, and phantom reading is inserting data.
Timeline transaction 1 transaction 2 begin; select * from lock where id = 1; begin; update lock set name='non-rr'; commit; select * from lock where id = 1 Commit
MySQL solves the above three problems by isolating transactions.
There are four levels of isolation.
Isolation level dirty read phantom read non-repeatable read uncommitted read (RUC) committed read (RC) whether it is repeatable read (RR) No serializable No
MySQL implements transaction isolation through locking mechanism.
The categories of locks are as follows
For the above about the necessity and types of locks in MySQL, do you think it is very helpful? If you need to know more, please continue to follow our industry information. I'm sure you'll like it.
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: 0
*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.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.