当前位置:网站首页>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 .
边栏推荐
- Nodejs 通过Heidisql连接mysql出现ER_BAD_DB_ERROR: Unknown database 'my_db_books'
- mongodb集群
- CTF_ Web: Advanced questions of attack and defense world expert zone WP (15-18)
- GBASE 8s的数据导入和导出
- 515. 在每个树行中找最大值 / 剑指 Offer II 095. 最长公共子序列
- GBASE 8s的并行操作问题场景描述
- kenlm
- Laravel document sorting 7. View
- CTF_ Web: deserialization of learning notes (II) CTF classic test questions from shallow to deep
- 彻底理解数据库事务
猜你喜欢

LabVIEW开发气体调节器

GBASE 8s 索引R树

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

Laravel document sorting 4. Controller
![LeetCode 剑指Offer II 091 粉刷房子[动态规划] HERODING的LeetCode之路](/img/ad/69fce7cf064479a0ddd477fb935de2.png)
LeetCode 剑指Offer II 091 粉刷房子[动态规划] HERODING的LeetCode之路

Musk released humanoid robot. Why is AI significant to musk?

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

CTF_ Web: basic 12 questions WP of attack and defense world novice zone

微信小程序父子组件之间传值

论文笔记: 多标签学习 ESMC (没看懂, 还没写出来, 暂时放这里占个位置)
随机推荐
GBASE 8s的级联删除功能
GBASE 8s的包
Laravel document sorting 1. Installation and Preliminary Configuration
GBASE 8s的数据导入和导出
Office macro virus bounce shell experiment
Finereport displays and hides column data according to conditions
CTF_ Web: Advanced questions of attack and defense world expert zone WP (1-4)
GBase 8s的封锁技术的基本介绍
Watch out for the stolen face! So many risks of face recognition used every day?
Comparison of towe/ JIRA / tapd / Zen collaboration platforms
Laravel document sorting 9. Blade template
Retrofit source code analysis
BSC smart contract dividend mainstream currency | including marketing wallet | deflation | reflow | dividend free token | available for direct deployment
Sourcetree pulls the code and prompts to fill in authentic, but the configuration cannot change the user
LabVIEW开发气体调节器
IntStream API介绍
GBASE 8s 总体架构
Nodejs connects to MySQL through heidisql, and ER appears_ BAD_ DB_ ERROR: Unknown database 'my_ db_ books'
关于TCP连接三次握手的详细总结
What is data persistence?