当前位置:网站首页>Classification of gbase 8s locks
Classification of gbase 8s locks
2022-06-25 04:32:00 【Eight delicacies tofu】
The object of the lock is the data object in the database , Such as tables in relational databases 、 Record 、 attribute 、 Index, etc. , The time to lock a data object is before the transaction operates on it , Send a lock request to the system . After locking, the transaction obtains control over the data object , Before a transaction releases its lock , Other transactions cannot enter this data object Do anything . Blocking is a queuing mechanism , Queue parallel tasks in lock order , Turn parallel tasks into strings Line task . GBase8s Adopt the blocking mechanism of global management , Allocation of a memory set in shared memory to mark lock usage , Keep the owner of the lock in each lock structure 、 Locked objects ( It's a watch 、 Record 、 Or OK )、 The type of lock, etc . stay GBase8s Each lock in the occupies 128 Byte.
1. Database level lock (Database-Ievel Locks)
Before we pass CONNECT DATABASE perhaps CREATE DATABASE Statement accessing the database , The system will automatically add a share to the database (S) lock , This prevents other users from deleting the database or The user adds and excludes it on the database (X) lock .
2. Table lock (Table-Ievel Locks) Table level lock means that the locked object is a table , You can explicitly lock and release the table with the following statement :
BEGIN WORK;
LOCK TABLE tab1 IN EXCLUSIVE MODE;
LOCK TABLE tab2 IN SHARE MODE;
UNLOCK TABLE tab1;
Perform the following DDL When the sentence is ,GBase8t It will automatically lock the table , Such as ALTER FRAGMENT、 ALTER INDEX、ALTER TABLE、CREATE INDEX ( If not used ONLINE Pattern )、DROP INDEX( If not used ONLINE Pattern )、RENAME COLUMN、RENAME TABLE.
When the entire table or most of the data in the table needs to be updated , The efficiency of using table lock is high .
3. Page level lock (Page Locks)
GBase8t Physically store multiple lines of records on the data page (Page) On , Page level lock means that the object of the lock is a piece of data page , When using page level locks to access records ,GBase8t The accessed data page will be locked automatically . When in physical order When accessing and updating multiple records , Using page level locks is more efficient .
You can specify the page lock mode as follows :
ALTER TABLE tab1 LOCK MODE (PAGE);
CREATE TABLE tab1 (…) LOCK MODE PAGE ;
CREATE TABLE If the lock mode is not specified , ... will be used ONCONFIG Parameters DEF_TABLE_ LOCKMODE To specify the locking mode of the table .
4. Row-level locks (Row Locks)
The data of relational database is managed by rows , So row level locks are easy to understand . stay OLTP Bank level in the system Locks are widely used , Only a small number of records accessed need to be locked , Using row level locks is more efficient .
The row level lock mode can be specified as follows :
ALTER TABLE tab1 LOCK MODE (ROW);
CREATE TABLE tab1 (…) LOCK MODE ROW ;
CREATE TABLE If the lock mode is not specified , ... will be used ONCONFIG Parameters DEF_TABLE_ LOCKMODE To specify the locking mode of the table .
5. Index lock (Index key)
The index uses B+ The storage structure of the tree , Therefore, the lock management of the index is to manage the index Key value . Database mining be widely used 、 Lock management of index in the way of closed area , Examples are as follows :
Create table tab1 (c1 int,c2 int) lock mode row;
Create unique index idx_tab1 on tab1(c1);
Insert into tab1 values(1,2);
Insert into tab1 values(2,2);
Insert into tab1 values(3,2);
Assume that only the above 3 rows , When executed update tab1 set c1=0 where c1>=3; When the sentence is ,GBase8t The index will be key The value is 3 Lock the closed section of records , This means that you cannot add key Greater than 3 The record of . If you execute at this time insert into tab1 values(4,2), Will prompt Index Lock conflict error .
边栏推荐
- LabVIEW开发气体调节器
- CTF_ Web: file contains pseudo protocol with PHP
- [kubernetes series] installation and use of Helm
- LeetCode 劍指Offer II 091 粉刷房子[動態規劃] HERODING的LeetCode之路
- Lecture record: data processing methods and applications of various spatial geodetic techniques
- 第二十五周记录
- CTF_ Web: Advanced questions of attack and defense world expert zone WP (1-4)
- 【openwrt】推荐一个国内开发的openwrt的版本,iStoreOS简介,非常好用,主要是做了一些优化。解决了汉化的问题。
- A-table mouse over the display hand, the current line can be clicked
- 关于TCP连接四次握手(或者叫四次挥手)的详细总结
猜你喜欢

Finereport displays and hides column data according to conditions

【esp32学习之路6——flash加密】

论文阅读《LSD-SLAM: Large-Scale Direct Monocular SLAM》

How much do you know about the use value of WMS warehouse management system

CTF_ Web: Learn flask template injection (SSTI) from 0

Coinlist how to operate the middle lot number security tutorial

关于TCP连接四次握手(或者叫四次挥手)的详细总结

Text keyword extraction: ansj

Anaconda安装+TensorFlow安装+Keras安装+numpy安装(包含镜像和版本信息兼容问题)

讲座记录《多种空间大地测量技术的数据处理方法和应用》
随机推荐
Laravel document sorting 4. Controller
Leetcode points to the leetcode road of offering II 091 house painting [dynamic planning] heroding
What is data persistence?
Text keyword extraction: ansj
Watch out for the stolen face! So many risks of face recognition used every day?
【esp32学习之路6——flash加密】
什么是数据持久化?
SQL, CTE, flg case problems
UCLA | 用于黑盒优化的生成式预训练
关于TCP连接三次握手的详细总结
小白学习MySQL - 统计的'投机取巧'
UCLA | generative pre training for black box optimization
GBASE 8s的并行操作问题场景描述
单元测试覆盖率
Nodejs connects to MySQL through heidisql, and ER appears_ BAD_ DB_ ERROR: Unknown database 'my_ db_ books'
GBase 8s 锁的分类
Finereport (sail soft) handling the problem that the histogram data label is blocked
kenlm
Error 1062 is reported during MySQL insertion, but I do not have this field.
Coinlist queuing tutorial to improve the winning rate