当前位置:网站首页>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 .
边栏推荐
- Internal sort - insert sort
- 因员工将密码设为“123456”,AMD 被盗 450Gb 数据?
- Electronic remote error
- 解析PHP跳出循环的方法以及continue、break、exit的区别介绍
- Substance painter notes: settings for multi display and multi-resolution displays
- GAN发明者Ian Goodfellow正式加入DeepMind,任Research Scientist
- Excuse me, does PTS have a good plan for database pressure measurement?
- Instructions for mictr01 tester vibrating string acquisition module development kit
- Navigation — 这么好用的导航框架你确定不来看看?
- Reading and understanding of eventbus source code
猜你喜欢
什么是云原生?这回终于能搞明白了!
13 ux/ui/ue best creative inspiration websites in 2022
【愚公系列】2022年7月 Go教学课程 005-变量
今日睡眠质量记录78分
Today's sleep quality record 78 points
Notes de l'imprimante substance: paramètres pour les affichages Multi - écrans et multi - Résolutions
数据湖(九):Iceberg特点详述和数据类型
Démontage de la fonction du système multi - Merchant Mall 01 - architecture du produit
JSON解析实例(Qt含源码)
Base64 encoding
随机推荐
Reading and understanding of eventbus source code
Data Lake (IX): Iceberg features and data types
Computer win7 system desktop icon is too large, how to turn it down
Webrtc audio anti weak network technology (Part 1)
Electronic remote error
Infinite innovation in cloud "vision" | the 2022 Alibaba cloud live summit was officially launched
小米的芯片自研之路
CPU与chiplet技术杂谈
属性关键字ServerOnly,SqlColumnNumber,SqlComputeCode,SqlComputed
electron remote 报错
回归测试的分类
寺岗电子称修改IP简易步骤
ES日志报错赏析-trying to create too many buckets
6. Electron borderless window and transparent window lock mode setting window icon
ES日志报错赏析-- allow delete
一文读懂数仓中的pg_stat
Leetcode——236. The nearest common ancestor of binary tree
电脑Win7系统桌面图标太大怎么调小
Substance Painter笔记:多显示器且多分辨率显示器时的设置
Simple use of websocket