当前位置:网站首页>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 .
边栏推荐
- CTF_ Web: Advanced questions of attack and defense world expert zone WP (1-4)
- Detailed explanation of flex attributes in flex layout
- cnpm : 无法加载文件 C:\Users\Administrator\AppData\Roaming\npm\cnpm.ps1,因为在此系统上禁止运行脚本。
- Acmstreamopen return value problem
- GBASE 8s的隔离级别介绍
- Coinlist how to operate the middle lot number security tutorial
- A detailed summary of TCP connection triple handshake
- ThinkPHP is integrated with esaywechat. What's wrong with wechat payment callback without callback?
- Read lsd-slam: large scale direct monolithic slam
- CTF_ Variable coverage in web:php
猜你喜欢

Nodejs 通过Heidisql连接mysql出现ER_BAD_DB_ERROR: Unknown database 'my_db_books'

Acmstreamopen return value problem

GBASE 8s 总体架构

Coinlist queuing tutorial to improve the winning rate

GBASE 8s 索引B+树

无法安装redis接口

How to draw an industry investment map

A detailed summary of four handshakes (or four waves) over TCP connections

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

Easyrecovery15 very easy to use computer data recovery software
随机推荐
记录小知识点
深度学习——几种学习类型
Retrofit source code analysis
Zoran community
GBASE 8s存储过程执行和删除
ThinkPHP is integrated with esaywechat. What's wrong with wechat payment callback without callback?
95% of programmers fish here
Nodejs 通过Heidisql连接mysql出现ER_BAD_DB_ERROR: Unknown database 'my_db_books'
2020.3.3 notes async/await and promise and Then processes and threads
GBASE 8S内存管理
彻底理解数据库事务
1280_C语言求两个无符号整形的平均值
PostgreSQL数据库WAL——RM_HEAP_ID日志记录动作
OBS Browser+浏览器的基本使用
Laravel document sorting 8. Middleware
L'épée leetcode fait référence au chemin leetcode de l'offre II 091 pour peindre la maison [planification dynamique] heroding
Failed to install redis interface
GBASE 8s的包
使用文本分析识别一段文本中的主要性别
Finereport displays and hides column data according to conditions