当前位置:网站首页>[MySQL transaction]
[MySQL transaction]
2022-07-04 06:56:00 【No trace after wind 2018】
MySQL Basic knowledge of business
Business : A set of logical operating units , To change data from one state to another .
The transaction ACID characteristic
- Atomicity (atomicity):
Atomicity means that a transaction is an indivisible unit of work , Or submit it all , Either all failures roll back . - Uniformity (consistency):
Consistency refers to before and after transaction execution , Data from a legal state ( Meet the constraints in reality ) Change to another state of legitimacy . This state is Semantically Not grammatical , Related to specific business . - Isolated type (isolation):
Transaction isolation means that the execution of one transaction cannot be interfered by other transactions , That is, the internal operations of a transaction and the concurrency of the data pairs used Other transactions are isolated , Transactions that execute concurrently cannot interfere with each other . - persistence (durability):
Persistence means that once a transaction is committed , It changes the data in the database permanently , Other subsequent operations and database failures should not have any impact on it .
Data concurrency problem
The server handles multiple transactions at the same time , We want to maintain the isolation of transactions , And I want the server to have higher performance when processing transactions , The isolation level is used
Transactions that access the same data , What problems may occur during concurrent execution :
- Dirty write ( Dirty Write )
For two things Session A、Session B, If the transaction Session A Revised the other one Not submitted Business Session B A modified Number of numbers
According to the , That means something happened Dirty write - Dirty reading ( Dirty Read )
For two things Session A、Session B,Session A Read It has been Session B to update But Not submitted Field of .
Later, if Session B Roll back ,Session A Read The content of is Temporary and invalid Of . - It can't be read repeatedly ( Non-Repeatable Read )
For two things Session A、Session B,Session A Read It's a field , then Session B to update This field . after
Session A Read again Same field , The value is different 了 . That means that non repeatable . - Fantasy reading ( Phantom )
For two things Session A、Session B, Session A From a table Read It's a field , then Session B In the table insert Enter into Some new ones . after , If Session A Read again The same watch , There will be more lines . That means unreal reading .
MySQL Transaction isolation level for
MySQL The default isolation level for is REPEATABLE READ( Repeatable )
Higher isolation level , The better the data consistency , But the less concurrent .
- READ UNCOMMITTED : Read uncommitted , At this isolation level , All transactions can see the results of other uncommitted transactions . Can't avoid dirty reading 、 It can't be read repeatedly 、 Fantasy reading .
- READ COMMITTED : Read submitted , It satisfies the simple definition of isolation : A transaction can only see changes that have been committed by the transaction . This is the default isolation level for most database systems ( But it's not MySQL default ). Avoid dirty reading , But not repeatable 、 The unreal reading problem still exists .
- REPEATABLE READ : Repeatable , Business A After reading a piece of data , At this point, the transaction B This data has been modified and submitted , The transaction A Reread the data , Read the original content . Avoid dirty reading 、 It can't be read repeatedly , But the problem of unreal reading still exists . This is a MySQL The default isolation level of .
- SERIALIZABLE : Serializable , Make sure that transactions can read the same rows from a table . During the duration of this transaction , Prevent other transactions from inserting into the table 、 Update and delete operations . All concurrency problems can be avoided , But the performance is very low . It can avoid dirty reading 、 No repeated reading or phantom reading .

边栏推荐
- tars源码分析之5
- 期末周,我裂开
- thread priority
- Summary of leetcode BFS question brushing
- Check and display one column in the known table column
- How can the old version of commonly used SQL be migrated to the new version?
- Highly paid programmers & interview questions: how does redis of series 119 realize distributed locks?
- Su Weijie, a member of Qingyuan Association and an assistant professor at the University of Pennsylvania, won the first Siam Youth Award for data science, focusing on privacy data protection, etc
- JS common time processing functions
- [Valentine's day] - you can change your love and write down your lover's name
猜你喜欢

selenium IDE插件下载安装使用教程

Deep profile data leakage prevention scheme

uniapp 自定義環境變量

notepad++如何统计单词数量

云Redis 有什么用? 云redis怎么用?
![[GF (q) + LDPC] regular LDPC coding and decoding design and MATLAB simulation based on the GF (q) field of binary graph](/img/5e/7ce21dd544aacf23b4ceef1ec547fd.png)
[GF (q) + LDPC] regular LDPC coding and decoding design and MATLAB simulation based on the GF (q) field of binary graph

uniapp小程序分包

Flink memory model, network buffer, memory tuning, troubleshooting

Set JTAG fuc invalid to normal IO port

Knowledge payment applet dream vending machine V2
随机推荐
Bottom problem of figure
Download kicad on Alibaba cloud image station
2022 wechat enterprise mailbox login entry introduction, how to open and register enterprise wechat enterprise mailbox?
金盾视频播放器拦截的软件关键词和进程信息
【网络数据传输】基于FPGA的百兆网/兆网千UDP数据包收发系统开发,PC到FPGA
leetcode825. 适龄的朋友
Tar source code analysis Part 10
How notepad++ counts words
Research on an endogenous data security interaction protocol oriented to dual platform and dual chain architecture
uniapp 自定義環境變量
How does the inner roll break?
Explain in one sentence what social proof is
Deep understanding of redis -- a new type of bitmap / hyperloglgo / Geo
Highly paid programmers & interview questions: how does redis of series 119 realize distributed locks?
Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
ABCD four sequential execution methods, extended application
Option (024) - do all objects have prototypes?
Su Weijie, a member of Qingyuan Association and an assistant professor at the University of Pennsylvania, won the first Siam Youth Award for data science, focusing on privacy data protection, etc
Download address of the official website of national economic industry classification gb/t 4754-2017
CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions