当前位置:网站首页>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 .
边栏推荐
- Webrtc audio anti weak network technology (Part 1)
- Differences between cookies and sessions
- AWS学习笔记(三)
- In the field of software engineering, we have been doing scientific research for ten years!
- Ascend 910实现Tensorflow1.15实现LeNet网络的minist手写数字识别
- 多商戶商城系統功能拆解01講-產品架構
- FFmpeg----图片处理
- Beginner JSP
- Notes de l'imprimante substance: paramètres pour les affichages Multi - écrans et multi - Résolutions
- The method of parsing PHP to jump out of the loop and the difference between continue, break and exit
猜你喜欢

华为云数据库DDS产品深度赋能

#yyds干货盘点# 解决名企真题:交叉线

Instructions d'utilisation de la trousse de développement du module d'acquisition d'accord du testeur mictr01

How bad can a programmer be? Nima, they are all talents

EfficientNet模型的完整细节

LeetCode 648. Word replacement

MicTR01 Tester 振弦采集模块开发套件使用说明

Cvpr2022 | backdoor attack based on frequency injection in medical image analysis

Ian Goodfellow, the inventor of Gan, officially joined deepmind as research scientist

PyTorch模型训练实战技巧,突破速度瓶颈
随机推荐
一个程序员的水平能差到什么程度?尼玛,都是人才呀...
云上“视界” 创新无限 | 2022阿里云直播峰会正式上线
找到自己的价值
Five pain points for big companies to open source
Démontage de la fonction du système multi - Merchant Mall 01 - architecture du produit
Leetcode——236. The nearest common ancestor of binary tree
Leetcode - Sword finger offer 05 Replace spaces
关于后台动态模板添加内容的总结 Builder使用
比尔·盖茨晒48年前简历:“没你们的好看”
Lidar Knowledge Drop
Substance painter notes: settings for multi display and multi-resolution displays
Delete a whole page in word
AWS学习笔记(三)
数据库如何进行动态自定义排序?
属性关键字ServerOnly,SqlColumnNumber,SqlComputeCode,SqlComputed
Docker deploy Oracle
The world's first risc-v notebook computer is on pre-sale, which is designed for the meta universe!
Internal sort - insert sort
[server data recovery] a case of RAID data recovery of a brand StorageWorks server
Base64 encoding