当前位置:网站首页>Different operating with different locks, rounding
Different operating with different locks, rounding
2022-08-01 20:00:00 【dog studying hard】
- A read operation performed by a transaction using MVCC is called a consistent read (or snapshot read).All ordinary SELECT statements are snapshot reads under the RC (read committed) and RR (repeatable read) isolation levels. Consistent reads will not lock any records in the table, and other transactions can freely access the table.Make changes to records in
select * from table_nameselect * from table_name t1 Inner Join table_name_name t2 on t2.id = t1.id
- The lock read of the shared lock, if the current transaction executes the lock read, then the S lock (shared) will be added, and other transactions can continue to obtain the S lock of these records, but cannot obtain these records.The X lock cannot directly change these records.If other transactions want to acquire the corresponding X lock, they will be blocked and wait until the current transaction's S lock is released
select * from table_name LOCK IN SHARE MODE
- Exclusive lock lock read, if the statement is executed, X lock will be added to the record, other transactions cannot obtain the S lock of these records, nor can they obtain the X lock of these records, direct modification of these records is not allowed.If other transactions want to acquire the corresponding X lock or, they will be blocked until the corresponding record X lock is released after the current transaction is committed.
SELECT * FROM UPDATE
- DELETE operation: The process of performing a DELETE operation on a record is actually to first locate the position of the record in the B+ tree, then acquire the X lock of this record, and then perform the DELETE Mark operation (It can be simply understood as a lock read that acquires an X lock)
- UPDATE operation: UPDATE operation on a record is divided into 3 cases
- If the key value of the record has not been modified and the storage space occupied by the updated column has not changed before and after the modification, locate in the B+ tree firstGo to the location of this record, then obtain the X lock of the record, and finally modify it at the location of the original record.(The process of locating the record to be modified in the B+ tree first, and then acquiring the X lock of the record can be regarded as a lock read that acquires the X lock)
- If the key value of the record has not been modified and the storage space occupied by at least one updated column has changed before and after modification, locate this record in the B+ tree first.The location of the record, then obtain the X lock of the record, then delete the record completely (move the record into the garbage list completely), and finally insert a new record.(First locate the record to be modified and then the position in the B+ tree, and then then acquire the X lock of the record. It can be seen as a locked read that acquires the X lock, strong>The lock on the record associated with the completely deleted record will also be transferred to the newly inserted record)
- If the key value of the record is modified, it is equivalent to performing an INSERT operation after the DELETE operation on the original record, and the locking operation needs to be performed according to the rules of DELETE and INSETR
- INSERT operation: Under normal circumstances, a newly inserted record is protected by an implicit lock, and there is no need to generate a corresponding lock structure for it in memory.
边栏推荐
猜你喜欢
随机推荐
Oracle排序某个字段, 如果这个varchar2类型的字段有数字也有文字 , 怎么按照数字大小排序?
【个人作品】无线网络图传模块
【节能学院】智能操控装置在高压开关柜的应用
17. Load balancing
Creo5.0草绘如何绘制正六边形
openresty 动态黑白名单
30-day question brushing plan (5)
图文详述Eureka的缓存机制/三级缓存
【torch】张量乘法:matmul,einsum
Combining two ordered arrays
【kali-信息收集】(1.2)SNMP枚举:Snmpwalk、Snmpcheck;SMTP枚举:smtp-user-enum
安装win32gui失败,解决问题
10 个 PHP 代码安全漏洞扫描程序
二维、三维、四维矩阵每个维度含义解释
deploy zabbix
JS数组过滤
把 Oracle 数据库从 RAC 集群迁移到单机环境
17、负载均衡
通配符 SSL/TLS 证书
Heavy cover special | intercept 99% malicious traffic, reveal WAF offensive and defensive drills best practices