Professional Documents
Culture Documents
#.2
Wait Tree - Locks
SQL*Net ST Lock
TS Lock
Undo
Enqueue Types
DDL Locks – Data Dictionary
Row Cache
Library Cache Locks
Statspack
Top 5 Timed Events Avg %Total
~~~~~~~~~~~~~~~~~~ wait Call
Event Waits Time (s) (ms) Time
-------------------------- ------------ ----------- ------ ------
Enqueue 42 126 3000 96.5
CPU time 4 2.8
db file sequential read 165 1 4 .4
control file sequential read 214 0 1 .1
log file switch completion 2 0 40 .1
v$session_wait
SQL> select event, p1,p2,p3 from v$session_wait;
EVENT P1 P2 P3
----------------- -------------- ---------- ----------
enqueue 1415053318 589855 1592
Enqueue : Args
P1 = Type | mode
P2 = ID1 , depends on P1
P3 = ID2 , depends on P1
P1 P1RAW
---------- --------
1415053318 54580006
Type Mode
Lock = TX 6
Copyright 2006 Kyle Hailey
#.9
Modes
1 Null Null
2 SS Sub share
3 SX Sub exclusive
4 S Share
5 SSX Share/sub exclusive
6 X Exclusive
Types
CF – Control File
HW – High Water
SQ - Sequence
ST - Space Transaction
TM - DML
TS – Temporary Segment / Table Space
TX –Transaction
UL – DBMS_LOCK
UN – User Named
US – Undo Segment
TX
ID1 = RBS seg# | RBS slot #
ID2 = rbs wrap #
TM
ID1 = object id
ID2 = 0
Lock = TM
ID1 = object id
ID2 = 0
Select
substr(name,1,7) as "lock",parameter1,parameter2,parameter3 from
v$event_name
where name like 'enq%'
HOLDING_SESSION
---------------
10
Enqueue : TX 6 Example
Exclusive Row Level Lock
User 1 User 2
Enqueue : TX 6 v$session_wait
SQL> select event, p1,p2,p3 from v$session_wait;
EVENT P1 P2 P3
----------------- -------------- ---------- ----------
enqueue 1415053318 589855 1592
TX
ID1 = RBS seg# | RBS slot #
ID2 = rbs wrap #
TM
ID1 = object id
ID2 = 0
HOLDING_SESSION
---------------
10
Enqueue : TX 4
Index on p(id)
User 1 User 2
Enqueue : TX 4
SQL> select sid, type, id1, id2, lmode , request
from v$lock where type in ('TX', 'TM');
Enqueue : TX 4 - difficult
Difficult – uses modifying different data
ITL
Unique Key
Bitmap Index
Rare
Read only Tablespace
Free Lists
Two phase commit
Enqueue : TX 4 – ITL
Transaction 1 Info
DataBlock
Data Block
Transaction 2 Info
Header
Header
ITL
Data
Enqueue : TX 4 – ITL
DataBlock
Data Block
Header
Header
Transaction 1 Transaction 3
Transaction 2
Row 3
Row 2
Data
Row 1
Enqueue : TX 4 – ITL
SQL> select sid, type, id1, id2, lmode , request
from v$lock where type in ('TX', 'TM');
Enqueue : ST
Space Transaction Lock
Used in Dictionary Managed Tables
Solution
Got to Locally Managed Tablespaces
Enqueue : HW
Table
Header
Data
Enqueue : HW
Use Freelists
Cause multiple jumps in High Water Mark
Pre-Allocate Extents
Alter table XXXX allocate extent;
Hidden Parameter
bump_highwater_mark_count
ASSM
Automatic segment space management