当前位置:网站首页>数据库-当前读与快照读
数据库-当前读与快照读
2022-07-06 06:08:00 【雪峰.贵】
当前读:insert update delete for update
快照读:不加锁的非阻塞读,select。目的是为了提高并发性能
在RC隔离级别下,当前读与快照读结果是一样的。
在RR隔离级别下,当前读与快照读结果有可能是不一样的
例如
事务1 与事务2 都读了一条数据。
select * from user where id =1;
id money
1 200
事务2 修改数据
update user set money = 1000 where id = 1;
commit;
事务1 再读(快照读):
select * from user where id = 1;
id money
1 200
而在执行(当前读) select * from user where id = 1 for update;
id money
1 1000
RR 级别下非阻塞读的实现原理:
数据行实际还有3个字段分别为:
DB_TRX_ID :修改这个数据的事务ID
DB_ROLL_PRT:回滚指针
DB_ROW_ID:隐藏的行ID
事务id=1,把数据从12 改为了32。
- 该行加排他锁
- 复制修改前数据,到undo log里面
- 修改当前行数据,填写事务id,回滚指针
事务id=2,又对此行进行Field3进行修改. - 加排他锁
- 复制修改前数据,到undo
- 修改当前行数据,填写事务id,回滚指针
每做一次修改,都会生成一条UNDO log数据。在事务来快照读数据的时候会通过readView算法,用当前事务id与log的DB_TRX_ID比较来确定是取哪个版本的数据。
边栏推荐
- 曼哈顿距离和-打印菱形
- Detailed explanation of BF and KMP
- Overview of three core areas of Mathematics: algebra
- Interface test: what are the components of the URL in fiddler
- Seven imperceptible truths in software testing
- [paper reading] nflowjs: synthetic negative data intensive anomaly detection based on robust learning
- J'ai un chaton.
- 【Tera Term】黑猫带你学TTL脚本——嵌入式开发中串口自动化神技能
- 【API接口工具】postman-界面使用介绍
- Raised a kitten
猜你喜欢
数学三大核心领域概述:代数
【无App Push 通用测试方案
进程和线程的理解
Baidu online AI competition - image processing challenge: the 8th program of handwriting erasure
全程实现单点登录功能和请求被取消报错“cancelToken“ of undefined的解决方法
HCIA复习
Overview of three core areas of Mathematics: algebra
异常检测方法总结
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
[web security] nodejs prototype chain pollution analysis
随机推荐
Company video accelerated playback
全链路压测:构建三大模型
(5) Explanation of yolo-v3 core source code (3)
黑猫带你学eMMC协议第10篇:eMMC读写操作详解(read & write)
Eigen sparse matrix operation
[course notes] Compilation Principle
Novice entry SCM must understand those things
[postman] dynamic variable (also known as mock function)
【Postman】Collections-运行配置之导入数据文件
Usage of test macro of GTEST
[web security] nodejs prototype chain pollution analysis
二维码的前世今生 与 六大测试点梳理
isam2运行流程
[Thesis code] SML part code reading
selenium源码通读·9 |DesiredCapabilities类分析
GTSAM中李群的運用
The latest 2022 review of "graph classification research"
[postman] collections configuration running process
黑猫带你学UFS协议第8篇:UFS初始化详解(Boot Operation)
Leaflet map