当前位置:网站首页>PG basics -- Logical Structure Management (locking mechanism -- table lock)
PG basics -- Logical Structure Management (locking mechanism -- table lock)
2022-07-07 14:49:00 【51CTO】
pg There are two types of locks , Table level lock and row level lock .
Table lock
Table lock classification
ACCESS SHARE | Read only tables do not modify the table to apply for the lock mode | |
ROW SHARE | select for update and select for share Apply for the lock mode | |
ROW EXCLUSIVE | DML Apply for the lock mode | |
SHARE UPDATE EXCLUSIVE | VACUUM、ANALYZE、CREATE INDEX CONCURRENTLY Apply for the lock mode | |
SHARE | create index Apply for the lock mode | |
SHARE ROW EXCLUSIVE | Won't apply voluntarily | |
EXCLUSIVE | Won't apply voluntarily | |
ACCESS EXCLUSIVE | alter table ,drop table,truncate,reindex ,vacuum full Apply for the lock of this mode |
Table lock overview
Table lock only share and EXCLUSIVE Two kinds of , That is, read and write lock ,share The table cannot be modified after the read lock is added , Lock exclusive You cannot read or write after writing the lock , But after the multi version function , Modify a row of data , In fact, it doesn't change the original line , Instead, another row of data is copied , The modification is made on the new line , The transaction does not commit , Others cannot see the modified line , There is no need to block other users from reading data .
Under the multi version function ,ACCESS share Indicates that this lock is added , Even when the data is being modified , It is also allowed to read data , Another lock ACCESS EXCLUSIVE Even multi version features , Access to data is also not allowed .
Intent locks
The lock granularity of table lock is too large , There's a row level lock ,mysql Before obtaining row lock, you need to obtain intention lock ,pg It's similar to mysql Also have ROW_SHARE and ROW_EXCLUSIVE lock .
There is no conflict between intent locks , The conflict compatibility relationship between intentional and non intentional locks is the same as that between ordinary locks . It can be simply converted to X and S, Comparing compatibility .
SHARE UPDATE EXCLUSIVE
Is to put IX The incompatibility between locks becomes a more strict lock , For without FULL Of VACUUM,CREATE INDEX CONCURRENTLY Will apply for the lock .
SHAER ROW EXCLUSIVE
Equivalent to adding S Lock and IX lock
Table lock summary
PG The Communist Party of China 8 Seed lock , Shared lock SHARE And lock it EXCLUSIVE , Colleagues who modify data due to multiple versions are allowed to read data , Hence the ACCESS SHARE and ACCESS EXCLUSIVE lock .
In order to deal with the relationship between table lock and row lock , The concept of intention lock ,ROW_SHARE and ROW_EXCLUSIVE lock , But there will be no conflict between intention locks , To be more strict , There is SHARE
UPDATE EXCLUSIVE and SHARE ROW EXCLUSIVE lock .
边栏推荐
- 安恒堡垒机如何启用Radius双因素/双因子(2FA)身份认证
- Mlgo: Google AI releases industrial compiler optimized machine learning framework
- Substance painter notes: settings for multi display and multi-resolution displays
- 小程序目录结构
- MLGO:Google AI发布工业级编译器优化机器学习框架
- A laravel background management expansion package you can't miss - Voyager
- 昇腾体验官第五期随手记I
- Attribute keywords serveronly, sqlcolumnnumber, sqlcomputecode, sqlcomputed
- Deformable convolutional dense network for enhancing compressed video quality
- PyTorch模型训练实战技巧,突破速度瓶颈
猜你喜欢
Webrtc audio anti weak network technology (Part 1)
Substance Painter笔记:多显示器且多分辨率显示器时的设置
全球首款 RISC-V 笔记本电脑开启预售,专为元宇宙而生!
智汀不用Home Assistant让小米智能家居接入HomeKit
[today in history] July 7: release of C; Chrome OS came out; "Legend of swordsman" issued
2022年13个UX/UI/UE最佳创意灵感网站
AWS learning notes (III)
Navigation — 这么好用的导航框架你确定不来看看?
Data Lake (IX): Iceberg features and data types
华为云数据库DDS产品深度赋能
随机推荐
Reading and understanding of eventbus source code
Delete a whole page in word
Infinite innovation in cloud "vision" | the 2022 Alibaba cloud live summit was officially launched
数据库如何进行动态自定义排序?
【服务器数据恢复】某品牌StorageWorks服务器raid数据恢复案例
关于后台动态模板添加内容的总结 Builder使用
半小时『直播连麦搭建』动手实战,大学生技术岗位简历加分项get!
潘多拉 IOT 开发板学习(HAL 库)—— 实验12 RTC实时时钟实验(学习笔记)
Instructions for mictr01 tester vibrating string acquisition module development kit
leetcode:648. Word replacement [dictionary tree board + find the shortest matching prefix among several prefixes]
昇腾体验官第五期随手记I
Base64 encoding
属性关键字ServerOnly,SqlColumnNumber,SqlComputeCode,SqlComputed
Es log error appreciation -- allow delete
Half an hour of hands-on practice of "live broadcast Lianmai construction", college students' resume of technical posts plus points get!
Data Lake (IX): Iceberg features and data types
NLLB-200:Meta开源新模型,可互译200种语言
Data connection mode in low code platform (Part 2)
Substance Painter筆記:多顯示器且多分辨率顯示器時的設置
Five pain points for big companies to open source