当前位置:网站首页>Database - current read and snapshot read
Database - current read and snapshot read
2022-07-06 06:14:00 【Snow peak expensive】
The current reading :insert update delete for update
Read the snapshot : Non blocking read without lock ,select. The purpose is to improve concurrency
stay RC Under isolation level , The current read and snapshot read results are the same .
stay RR Under isolation level , The current read and snapshot read results may be different
for example
Business 1 And business 2 Read a piece of data .
select * from user where id =1;
id money
1 200
Business 2 Modifying data
update user set money = 1000 where id = 1;
commit;
Business 1 read ( Read the snapshot ):
select * from user where id = 1;
id money
1 200
And in the execution ( The current reading ) select * from user where id = 1 for update;
id money
1 1000
RR Implementation principle of non blocking read at level :
There are actually 3 The fields are :
DB_TRX_ID : Transactions that modify this data ID
DB_ROLL_PRT: rollback pointer
DB_ROW_ID: Hidden lines ID
Business id=1, The data from 12 Change it to 32.
- The bank adds an exclusive lock
- Copy the data before modification , To undo log Inside
- Modify the data of the current line , Fill in transactions id, rollback pointer
Business id=2, Again on this trip Field3 Make changes . - Add an exclusive lock
- Copy the data before modification , To undo
- Modify the data of the current line , Fill in transactions id, rollback pointer
Every time you make a modification , Will generate one UNDO log data . When the transaction snapshot reads data, it will pass readView Algorithm , Use the current transaction id And log Of DB_TRX_ID Compare to determine which version of data is taken .
边栏推荐
- 2022 software testing workflow to know
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- Detailed explanation of BF and KMP
- [wechat applet] build a development tool environment
- [eolink] PC client installation
- Expose the serial fraudster Liu Qing in the currency circle, and default hundreds of millions of Cheng Laolai
- 黑猫带你学UFS协议第8篇:UFS初始化详解(Boot Operation)
- About PHP startup, mongodb cannot find the specified module
- [C language] string left rotation
- D - How Many Answers Are Wrong
猜你喜欢
随机推荐
Aike AI frontier promotion (2.13)
JWT-JSON WEB TOKEN
Arrays and collections
IP day 16 VLAN MPLS configuration
Isam2 operation process
MySQL之基础知识
RestTemplate、Feign实现Token传递
【微信小程序】搭建开发工具环境
Detailed explanation of BF and KMP
公司视频加速播放
Isam2 and incrementalfixedlagsmooth instructions in gtsam
Online and offline problems
win10无法操作(删除、剪切)文件
【Tera Term】黑猫带你学TTL脚本——嵌入式开发中串口自动化神技能
Luogu p1460 [usaco2.1] healthy Holstein cows
Dynamic programming -- knapsack problem
在线问题与离线问题
GTSAM中李群的運用
10m25dcf484c8g (FPGA) amy-6m-0002 BGA GPS module
Reading notes of effective managers