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

Database ACID principles and transaction isolation levels

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Database ACID principle

A: atomicity, Atomicity

C: consistency, Consistency

I: isolation, Isolation

D: persistence, Durability

In the innodb engine in mysql, atomicity, consistency and isolation are realized through redo and undo. Redo is the ib_logfile physical file, while undo is in the shared tablespace ibdata by default, which can be separated by setting parameters.

Transaction isolation level

Read Uncommitted (read uncommitted): during the execution of a transaction, you can see the inserted and changed data that has not been committed by other transactions. The disadvantage is that dirty reads are allowed and write operations are not allowed at the same time, but other transactions are allowed to read uncommitted data, which has a big problem with the accuracy of the query.

Read Committed (read committed): during the execution of a transaction, you can see the newly inserted records that have been committed by other transactions, and you can see the updates to the existing records that have been committed by other transactions, that is, there may be situations where repeated queries of the same record will have different results, but it is indeed the data that has already been committed. The disadvantage is that it allows phantom reading (data that did not exist before but has been submitted later), does not allow simultaneous write operations, only allows reading of committed data, but allows non-repeatable reading (data that is read twice is allowed to be inconsistent), and the default isolation level for oracle and sqlserver.

Repeatable Read (repeatable readable): during the execution of a transaction, you can see the newly inserted records that have been committed by other transactions, but can not see the updates of other transactions to the existing records, that is, repeatedly querying the same record is consistent, prohibiting non-repeatable reading and dirty reading, but in extreme cases there will be phantom reading, which generally conforms to the ACID principle and is the default isolation level of mysql.

Serializable (serialization): transaction serialization, transactions can only be executed one after another, and in the process of execution, you can not see the updates made by other transactions to the database, the disadvantage is poor concurrency, the strictest transaction isolation, fully in line with ACID principles, but a greater impact on performance.

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.

Share To

Database

Wechat

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

12
Report