Enqueue Waits : Locks. #.2 Copyright 2006 Kyle Hailey Wait Tree - Locks Waits Disk I/O Library Cache Enqueue Undo TX 6 Row Lock TX 4 ITL Lock HW Lock.

Slides:



Advertisements
Similar presentations
Overview of performance tuning strategies Oracle Performance Tuning Allan Young June 2008.
Advertisements

The Architecture of Oracle
Wait-die Transactions given a timestamp when they arrive …. ts(T i ) T i can only wait for T j if ts(T i )< ts(T j )...else die T 1 (ts =10) T 2 (ts =20)
1 Wait Event Enhancements in Oracle 10g Terry Sutton and Roger Schrag Database Specialists, Inc.
IO Waits Kyle Hailey #.2 Copyright 2006 Kyle Hailey Waits Covered in this Section  db file sequential read  db file scattered.
Enqueue Waits : Locks. #.2 Copyright 2006 Kyle Hailey Locks REDO Lib Cache Buffer Cache IO Locks Network.
1/43 Tanel PoderEoug User2User day Freelists vs ASSM in Oracle9i Tanel Poder independent technology consultant 20-Oct-03 OracleWorld.
5 Copyright © 2005, Oracle. All rights reserved. Managing Database Storage Structures.
4 Copyright © 2005, Oracle. All rights reserved. Managing the Oracle Instance.
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Oracle High Availability Solutions RAC and Standby Database Copyright System Managers LLC 2008.
Manipulating Data Schedule: Timing Topic 60 minutes Lecture
17 Copyright © 2005, Oracle. All rights reserved. Performing Flashback.
Understanding Locks and Enqueues How to Approach Common Blocking Lock Scenarios By Mark J. Bobak November 20 th, 2008.
Buffer Cache Waits. #.2 Copyright 2006 Kyle Hailey Buffer Cache Waits Waits Disk I/O Buffer Busy Library Cache Enqueue SQL*Net Free Buffer Hot Blocks.
Acknowledgments Byron Bush, Scott S. Hilpert and Lee, JeongKyu
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Performance And Tuning – Lecture 7 Copyright System Managers LLC 2007 all rights reserved.
1 - Oracle Server Architecture Overview
Harvard University Oracle Database Administration Session 2 System Level.
Harvard University Oracle Database Administration Session 5 Data Storage.
9 Copyright © 2009, Oracle. All rights reserved. Managing Data Concurrency.
Redo Waits Kyle Hailey #.2 Copyright 2006 Kyle Hailey Log File Waits  Redo is written to disk when  User commits  Log Buffer.
Redo Waits Kyle Hailey #.2 Copyright 2006 Kyle Hailey Redo REDO Lib Cache Buffer Cache Locks Network I/O.
Waits Defined Kyle Hailey #.2 Copyright 2006 Kyle Hailey Top 36 Foreground Waits write complete waits library cache.
1 Copyright © 2009, Oracle. All rights reserved. Exploring the Oracle Database Architecture.
Oracle Database Administration Database files Logical database structures.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
#.1 Oracle Wait Interface in Oracle 10g. #.2 Today’s Session  Twelve wait event interface enhancements in Oracle 10g that we really like.  Documentation.
DBMS Transactions and Rollback Recovery Helia / Martti Laiho.
Part II : Waits Events Kyle Hailey
Wait-Time Based Oracle Performance Management Prepared for Ohio Oracle User Group Presented by Dean Richards Senior Engineer, Confio Software.
Extents, segments and blocks in detail. Database structure Database Table spaces Segment Extent Oracle block O/S block Data file logical physical.
Architecture Rajesh. Components of Database Engine.
Buffer Cache Waits. In This Section 1.latch: cache buffers chains 2.latch: cache buffers lru chain 3.Free Buffer Wait 4.Buffer Busy Wait 5.Write Complete.
Oracle Locking Michael Messina Principal Database Analyst Indiana University.
Buffer Cache Waits. #.2 In This Section 1.latch: cache buffers chains 2.latch: cache buffers lru chain 3.latch: cache buffer handles 4.Free Buffer Wait.
1 Oracle Architectural Components. 1-2 Objectives Listing the structures involved in connecting a user to an Oracle server Listing the stages in processing.
Copyright  Oracle Corporation, All rights reserved. 1 Oracle Architectural Components.
Copyright © Oracle Corporation, All rights reserved. 1 Oracle Architectural Components.
Chapter 6 Additional Database Objects Oracle 10g: SQL.
An Oracle server:  Is a database management system that provides an open, comprehensive, integrated approach to information management.  Consists.
9 Storage Structure and Relationships. 9-2 Objectives Listing the different segment types and their uses Controlling the use of extents by segments Stating.
9 Copyright © 2007, Oracle. All rights reserved. Managing Data and Concurrency.
Oracle9i Performance Tuning Chapter 12 Tuning Tools.
Achieving Scalability, Performance and Availability on Linux with Oracle 9iR2-RAC Grant McAlister Senior Database Engineer Amazon.com Paper
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
8 Copyright © 2005, Oracle. All rights reserved. Managing Data.
Database structure and space Management. Segments The level of logical database storage above an extent is called a segment. A segment is a set of extents.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
8 Copyright © 2007, Oracle. All rights reserved. Managing Schema Objects.
14 Copyright © 2006, Oracle. All rights reserved. Tuning Block Space Usage.
D Copyright © Oracle Corporation, All rights reserved. Loading Data into a Database.
#.6 Sampling Kyle Hailey
Harvard University Oracle Database Administration Session 6 Object Storage.
Oracle 10g Database Administrator: Implementation and Administration Chapter 5 Basic Storage Concepts and Settings.
Preface 1Performance Tuning Methodology: A Review Course Structure 1-2 Lesson Objective 1-3 Concepts 1-4 Determining the Worst Bottleneck 1-5 Understanding.
Chapter 3: Relational Databases
SQL*Net & Other Waits. #.2 Copyright 2006 Kyle Hailey SQL*Net Waits Session Shadow Log Buffer Buffer Cache Log Buffer Buffer Cache SGA Library Cache Host.
1 Indexes ► Sort data logically to improve the speed of searching and sorting operations. ► Provide rapid retrieval of specified rows from the table without.
1 11g NEW FEATURES ByVIJAY. 2 AGENDA  RESULT CACHE  INVISIBLE INDEXES  READ ONLY TABLES  DDL WAIT OPTION  ADDING COLUMN TO A TABLE WITH DEFAULT VALUE.
What is Oracle ? Oracle is a relational database management system. It is a management system which uses the relational data model. In the relational data.
Oracle Database Architectural Components
1 PVSS Oracle scalability Target = changes per second (tested with 160k) changes per client 5 nodes RAC NAS 3040, each with one.
Chapter 21 SGA Architecture and Wait Event Summarized & Presented by Yeon JongHeum IDS Lab., Seoul National University.
Database structure and space Management
Oracle 10g Database Administrator: Implementation and Administration
Kyle Hailey Enqueue Waits : Locks Kyle Hailey
Index Index.
CS347 Spring 2017 – Quiz 5 Preparation - Solutions UTEID _________
Database administration
Presentation transcript:

Enqueue Waits : Locks

#.2 Copyright 2006 Kyle Hailey Wait Tree - Locks Waits Disk I/O Library Cache Enqueue Undo TX 6 Row Lock TX 4 ITL Lock HW Lock Redo Buffer Cache SQL*Net TM 3 Row Lock ST Lock TS Lock TX 4 PK/FK

#.3 Copyright 2006 Kyle Hailey Enqueue Types  DDL Locks – Data Dictionary  Row Cache  Library Cache Locks  DML Locks – Data Locks  Row locks  Table Locks  Internal Structure Locks  High Water  Buffer Header  Sequence Cache  Space Transaction  Temporary Space

#.4 Copyright 2006 Kyle Hailey Statspack Top 5 Timed Events Avg %Total ~~~~~~~~~~~~~~~~~~ wait Call Event Waits Time (s) (ms) Time Enqueue CPU time db file sequential read control file sequential read log file switch completion Top 5 Timed Events Avg %Total ~~~~~~~~~~~~~~~~~~ wait Call Event Waits Time (s) (ms) Time Enqueue CPU time db file sequential read control file sequential read log file switch completion Need more info from v$session_wait

#.5 Copyright 2006 Kyle Hailey v$session_wait SQL> select event, p1,p2,p3 from v$session_wait; EVENT P1 P2 P enqueue SQL> select event, p1,p2,p3 from v$session_wait; EVENT P1 P2 P enqueue What can we do with this info? Note: v$session_wait is for current waits. Need ASH or some similar data source for historic analysis

#.6 Copyright 2006 Kyle Hailey Enqueue : Args  P1 = Type | mode  P2 = ID1, depends on P1  P3 = ID2, depends on P1

#.7 Copyright 2006 Kyle Hailey Translating P1 to Lock and Mode SQL> select p1, p1raw from v$session_wait where sid=151; P1 P1RAW Mode Type

#.8 Copyright 2006 Kyle Hailey Translating P1 to Lock and Mode Type: 5458 P1RAW Hex Decimal ASCII 54 = 84 = “T” 58 = 88 = “X” Lock = TX 6 Mode: 0006

#.9 Copyright 2006 Kyle Hailey Translating P1 to Lock and Mode column Type format a4 column Mode format a4 select sid, chr(to_number(substr(p1raw,1,1)) * 16 + to_number(substr(p1raw,2,1))) || chr(to_number(substr(p1raw,3,1)) * 16 + to_number(substr(p1raw,4,1))) Type, substr(p1raw,8,1) as "Mode" from v$session_wait where name=‘enqueue’; SID TYPE Mode TX 06

#.10 Copyright 2006 Kyle Hailey Translating p1 to Lock and Mode SELECT chr(bitand(p1, )/ )|| chr(bitand(p1, )/65535) "Lock", mod(p1,16) as "mode" FROM V$SESSION_WAIT Where sid=151 / bitand(p1, 65536) "Mode"

#.11 Copyright 2006 Kyle Hailey Translating P1 to Lock and Mode select sid, event, chr(bitand(P1, )/ )|| chr(bitand(P1, )/65535) as "Type", mod(p1,16) as "mode" from v$session_wait where event = 'enqueue‘; select sid, event, chr(bitand(P1, )/ )|| chr(bitand(P1, )/65535) as "Type", mod(p1,16) as "mode" from v$session_wait where event = 'enqueue‘; SID EVENT Ty mode P2 P enqueue TX SID EVENT Ty mode P2 P enqueue TX

#.12 Copyright 2006 Kyle Hailey Modes 1 Null Null 2 SS Sub share 3 SX Sub exclusive 4 S Share 5 SSX Share/sub exclusive 6 X Exclusive

#.13 Copyright 2006 Kyle Hailey 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

#.14 Copyright 2006 Kyle Hailey Looking at v$lock select * from v$lock where type in ('TX', 'TM'); SID TY ID1 ID2 LMODE REQUEST CTIME BLOCK TX TM TM TX select * from v$lock where type in ('TX', 'TM'); SID TY ID1 ID2 LMODE REQUEST CTIME BLOCK TX TM TM TX TX ID1 = RBS seg# | RBS slot # ID2 = rbs wrap # TM ID1 = object id ID2 = 0

#.15 Copyright 2006 Kyle Hailey ID1 and ID2 Examples  Lock = TX  ID1 = RBS seg# | RBS slot #  ID2 = rbs wrap #  Lock = TM  ID1 = object id  ID2 = 0 ID1 and ID2 meanings can be determined from v$event_name in 10g

#.16 Copyright 2006 Kyle Hailey ID1 and ID2 Definitions column parameter1 format a15 column parameter2 format a15 column parameter3 format a15 column lock format a8 Select substr(name,1,7) as "lock",parameter1,parameter2,parameter3 from v$event_name where name like 'enq%' LOCK Parmeter1 Parmeter2(ID1) Parameter3(ID2) enq: CF name|mode 0 operation enq: HW name|mode table space # block enq: SQ name|mode object # 0 enq: ST name|mode 0 0 enq: TM name|mode object # table/partition enq: TS name|mode tablespace ID dba enq: TX name|mode usn<<16 | slot sequence

#.17 Copyright 2006 Kyle Hailey Enqueues Decoded in 10g  10gR2 waits distinguish 208 enqueues enq: DB - contention Administrative enq: HW - contention Configuration enq: KO - fast object checkpoint Application enq: PW - flush prewarm buffers Application enq: RO - contention Application enq: RO - fast object reuse Application enq: SQ - contention Configuration enq: SS - contention Configuration enq: ST - contention Configuration enq: TM - contention Application enq: TW - contention Administrative enq: TX - allocate ITL entry Configuration enq: TX - index contention Concurrency enq: TX - row lock contention Application enq: UL - contention Application enq: ZG - contention Administrative

#.18 Copyright 2006 Kyle Hailey Enqueue Solutions SQ – Sequence Lock logon/logoff problem TX - mode 6 – application problem Look at what application is doing Find SQL Look at locked data TX - mode 4 probably ITL problem find the object and SQL HW – High Water Look at object and SQL use LMT, freelists, pre-allocate extents, ST - Space Transaction only one per database used for space allocations uet, fet Find object use LMT UL - User Lock find out what application is doing

#.19 Copyright 2006 Kyle Hailey Enqueue Data Needed  If highest wait time is Enqueue,  Find out the kind of Enqueue and tune it  To tune enqueues we need one of the following to determine the type of enqueue  ASH Data  v$session_wait data  Sql Trace with waits

#.20 Copyright 2006 Kyle Hailey Blockers and Waiters SQL> select * from dba_blockers; HOLDING_SESSION SQL> select * from dba_waiters; WAITING HOLDING LOCK_TYPE MODE_HELD MODE_REQUESTE LOCK_ID1 LOCK_ID Transaction Exclusive Exclusive

#.21 Copyright 2006 Kyle Hailey V$session select sid, row_wait_obj#, row_wait_file#, row_wait_block#, row_wait_row#, lockwait from v$session; SID ROW_WAIT_OBJ# ROW_WAIT_FILE# ROW_WAIT_BLOCK# ROW_WAIT_ROW# LOCKWAIT AC 10g Lockwait not null is blocker Pre-10g Lockwait not null is the waiter

#.22 Copyright 2006 Kyle Hailey Enqueue : TX 6 Example User 1 SQL> delete from emp where empno = 7934; User 2 SQL> update emp set sal=2000 Where empno = 7934;   Exclusive Row Level Lock

#.23 Copyright 2006 Kyle Hailey Enqueue : TX 6 v$session_wait SQL> select event, p1,p2,p3 from v$session_wait; EVENT P1 P2 P enqueue SQL> select event, p1,p2,p3 from v$session_wait; EVENT P1 P2 P enqueue What can we do with this info?

#.24 Copyright 2006 Kyle Hailey Enqueue : TX 6 Type and Mode select sid, event, chr(bitand(P1, )/ )|| chr(bitand(P1, )/65535) as "Type", mod(p1,16) as "mode" from v$session_wait where event = 'enqueue‘; select sid, event, chr(bitand(P1, )/ )|| chr(bitand(P1, )/65535) as "Type", mod(p1,16) as "mode" from v$session_wait where event = 'enqueue‘; SID EVENT Ty mode P2 P enqueue TX SID EVENT Ty mode P2 P enqueue TX

#.25 Copyright 2006 Kyle Hailey Enqueue : TX 6 v$lock select * from v$lock where type in ('TX', 'TM'); SID TY ID1 ID2 LMODE REQUEST CTIME BLOCK TX TM TM TX select * from v$lock where type in ('TX', 'TM'); SID TY ID1 ID2 LMODE REQUEST CTIME BLOCK TX TM TM TX TX ID1 = RBS seg# | RBS slot # ID2 = rbs wrap # TM ID1 = object id ID2 = 0

#.26 Copyright 2006 Kyle Hailey Enqueue : TX 6 Blockers and Waiters SQL> select * from dba_blockers; HOLDING_SESSION SQL> select * from dba_waiters; WAITING HOLDING LOCK_TYPE MODE_HELD MODE_REQUESTE LOCK_ID1 LOCK_ID Transaction Exclusive Exclusive

#.27 Copyright 2006 Kyle Hailey Enqueue : TX 6 V$session select sid, row_wait_obj#, row_wait_file#, row_wait_block#, row_wait_row#, lockwait from v$session; SID ROW_WAIT_OBJ# ROW_WAIT_FILE# ROW_WAIT_BLOCK# ROW_WAIT_ROW# LOCKWAIT AC 10g Lockwait not null is blocker Pre-10g Lockwait not null is the waiter

#.28 Copyright 2006 Kyle Hailey Enqueue : TX 4 User 1 SQL> insert into p values(3); User 2 SQL> insert into p values(3);   Index on p(id)

#.29 Copyright 2006 Kyle Hailey Enqueue : TX 4 select sid, event, chr(bitand(P1, )/ )|| chr(bitand(P1, )/65535) as "Type", mod(p1,16) as "mode" from v$session_wait where event = 'enqueue‘; select sid, event, chr(bitand(P1, )/ )|| chr(bitand(P1, )/65535) as "Type", mod(p1,16) as "mode" from v$session_wait where event = 'enqueue‘; SID EVENT Ty mode P2 P enqueue TX SID EVENT Ty mode P2 P enqueue TX

#.30 Copyright 2006 Kyle Hailey Enqueue : TX 4 SQL> select sid, type, id1, id2, lmode, request from v$lock where type in ('TX', 'TM'); SID TY ID1 ID2 LMODE REQUEST TX TM TM TM TM TX TX

#.31 Copyright 2006 Kyle Hailey Enqueue : TX 4 - difficult Difficult – uses modifying different data  ITL  Unique Key  Bitmap Index Rare  Read only Tablespace  Free Lists  Two phase commit

#.32 Copyright 2006 Kyle Hailey Enqueue : TX 4 – ITL Data Block Header ITL Data Transaction 1 Info Transaction 2 Info

#.33 Copyright 2006 Kyle Hailey Enqueue : TX 4 – ITL Data Block Header Transaction 1 Data Data Block Header Transaction 2 Row 1 Row 2 Row 3 Transaction 3

#.34 Copyright 2006 Kyle Hailey Enqueue : TX 4 – ITL SQL> select sid, type, id1, id2, lmode, request from v$lock where type in ('TX', 'TM'); SID TY ID1 ID2 LMODE REQUEST TX TM TM TM TX TX SQL> select sid, type, id1, id2, lmode, request from v$lock where type in ('TX', 'TM'); SID TY ID1 ID2 LMODE REQUEST TX TM TM TM TX TX

#.35 Copyright 2006 Kyle Hailey Enqueue : TX 4 – Unique Key User 1 create table parent ( id number primary key); create table child ( id number references parent, name varchar2(20)); insert into parent values (1); insert into child values (1,2); commit; delete from parent; User 2 insert into child values (1,2);   Exclusive Row Level Lock

#.36 Copyright 2006 Kyle Hailey Enqueue : TX 4 – Unique Key Parent Child ID IDName ValueID PK Session 1: Insert into Child ID=1 Session 2: Delete from Parent ID=2 : would require a FTS of child still not atomic, solution lock child Enqueue TX 4

#.37 Copyright 2006 Kyle Hailey Enqueue : TX 4 - Unique Key SQL> select sid, type, id1, id2, lmode, request from v$lock where type in ('TX', 'TM'); SID TY ID1 ID2 LMODE REQUEST TM TM TX TM TM SQL> select sid, type, id1, id2, lmode, request from v$lock where type in ('TX', 'TM'); SID TY ID1 ID2 LMODE REQUEST TM TM TX TM TM

#.38 Copyright 2006 Kyle Hailey Enqueue : TX 4 – Unique Key Solution Parent Child ID IDName ValueID PK Session 1: Insert into Child ID=1 Session 2: Delete from Parent ID=2 OK – can verify quickly in the child index ID Index

#.39 Copyright 2006 Kyle Hailey Enqueue : TX 4 – V$session select sid, row_wait_obj#, row_wait_file#, row_wait_block#, row_wait_row#, lockwait from v$session; SID ROW_WAIT_OBJ# ROW_WAIT_FILE# ROW_WAIT_BLOCK# ROW_WAIT_ROW# LOCKWAIT B4EE1C g Lockwait not null is blocker Pre-10g Lockwait not null is the waiter

#.40 Copyright 2006 Kyle Hailey Enqueue : TX 4 – Bitmap Indexes  Two sessions update keys in same key range

#.41 Copyright 2006 Kyle Hailey Enqueue : ST  Space Transaction Lock  Used in Dictionary Managed Tables  Solution  Got to Locally Managed Tablespaces

#.42 Copyright 2006 Kyle Hailey Enqueue : HW Data Empty High Water Mark Header Table

#.43 Copyright 2006 Kyle Hailey Enqueue : HW select sid, event, chr(bitand(P1, )/ )|| chr(bitand(P1, )/65535) as "Type", mod(p1,16) as "mode" from v$session_wait where event = 'enqueue‘; select sid, event, chr(bitand(P1, )/ )|| chr(bitand(P1, )/65535) as "Type", mod(p1,16) as "mode" from v$session_wait where event = 'enqueue‘; SID EVENT Ty mode P2 P enqueue HW SID EVENT Ty mode P2 P enqueue HW

#.44 Copyright 2006 Kyle Hailey 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