SlideShare a Scribd company logo
Oracle Diagnostics
Hemant K Chitale
Hemant K Chitale
• whoami ?
• Oracle 5 to Oracle 10gR2 : DOS, Xenix,8
flavours of Unix, Linux, Windows
• Financial Services, Govt/Not-for-Profit, ERP,
Custom
• Production Support, Consulting, Development
• A DBA, not a Developer
• My Oracle Blog http://hemantoracledba.blogspot.com
Latches and Enqueues
• Latches are points of concurrency ; Enqueues
are points of serialisation.
• Three sessions may be waiting on a Latch – any
of the three may get the Latch before the other
two.
• If sessions are waiting on an Enqueue, access is
serialised – the first session to start waiting gets
the Enqueue first.
Latches
• Imagine a Wishing Well with place for only 1 person to stand in front of it
• Four persons approach the Wishing Well almost “simultaneously”
• Mr A gets to the well first and stands before it making his wish before dropping a coin
• The other three persons (B, C and D) loiter around. B wanders off to look at garden,
C sits down on a bench and D stands close to A. REMEMBER : There is no
convention that people must queue at a Wishing Well.
• A takes a long time making his wish and D get’s bored (his process has hit the “spin
count” limit for the number of No-Op spins it can do on the CPU) and wanders away.
He relinquishes his place.
• When A finishes and walks away, C rushes forward and get’s to the well first.
• In the meantime, E and F have also walked in on the scene.
• After C, D gets to the well.
• Before B can get back, E is next in making a wish at the well
Latches
• There you have it !
• There is no “sequencing” or “ordering”.
• A process may spin on the CPU waiting for a Latch but if it doesn’t get the latch, it
relinquishes the CPU and goes to “sleep”.
• It may not be the first process to get the Latch when it is released – some other
process happens to be lucky enough to get the Latch.
• Latches protect access to Memory Resources.
• A datablock for a table is loaded into the SGA as a Buffer. It may contain 20 different
rows.
• If 5 users need access to 5 different rows in that Buffer, they may get access to
modify the Buffer in any order. Oracle really doesn’t care which of the 5 users modify
the Buffer first --- as long as they are not modifying the same rows.
• Latches on Buffers are in the Headers that are on the Cache Buffers Chain lists – in-
memory linked lists.
Latches Diagnosis - 1
• Identify Latches with V$LATCHNAME,
V$LATCH, V$LATCH_PARENT,
V$LATCH_CHILDREN
• Latch Holders are in V$LATCHHOLDER
• Latches may be “willing-to-wait” and “no-
wait” latches
Latches Diagnosis - 2
• Statistics are presented “gets”, “misses”
and “sleeps” – 1,2,3… where the session
sleeps once or twice or thrice or four or
more times, because it was unable to “get”
the latch each time it awoke from it’s sleep
• Most commonly known latches :
– library cache ; shared pool
– cache buffers chains
Identifying Latches (listing from 11.2) :
SQL> select count(*) from v$latchname;
COUNT(*)
----------
535
SQL> select count(*) from v$latch;
COUNT(*)
----------
535
SQL> select count(*) from v$latch_parent;
COUNT(*)
----------
535
SQL> select count(*) from v$latch_children;
COUNT(*)
----------
2773
SQL>
SQL> desc v$latchholder
Name Null? Type
----------------------------------------- -------- ----------------------------
PID NUMBER
SID NUMBER
LADDR RAW(4)
NAME VARCHAR2(64)
GETS NUMBER
SQL>
Library Cache Latch usage :
This latch protects SQL statements, object definitions etc. Oracle internally
determines the number of latches available (as a prime number).
Adding new SQL statements and Objects require the Latch. One latch would
be protecting multiple SQLs.
Note : If you have DDLs modifying object definitions, there would be waits on
the Library Cache Latches protecting those objects.
Library Cache Pin Latch usage :
When a statement is re-executed (it has to be pinned to ensure that it is not
modified !
Shared Pool Latch :
This latch protects the allocation of memory in the Shared Pool. Multiple child
latches are created.
Frequent Hard Parsing of SQLs would cause frequent access to the Shared
Pool Latch.
Cache Buffers Chains Latch :
Protects Memory Buffers for Database Blocks. Multiple (Child) Latches are
present, each Latch protecting multiple buffers (blocks).
Blocks are loaded into memory based on a hash of the Database Block Address.
A Linked List of the Buffer Headers is maintained so that a Block can be found
quickly in the Buffer Cache.
Look for CBC Latches with very high SLEEPs – indicating very frequent retries.
Don’t run this query – it will take a long time on a busy instance / large database.
-- query from How To Identify a Hot Block Within The Database Buffer Cache. [ID 163424.1]
select /*+ RULE */
e.owner ||'.'|| e.segment_name segment_name,
e.extent_id extent#, x.dbablk - e.block_id + 1 block#,
x.tch, l.child#
from
sys.v$latch_children l,
sys.x$bh x,
sys.dba_extents e
where
x.hladdr = '&ADDR' and
e.file_id = x.file# and
x.hladdr = l.addr and
x.dbablk between e.block_id and e.block_id + e.blocks -1
order by x.tch desc ;
Typically Hot Blocks can be Index Root / Branch Blocks when an Index is
frequently used in a Nested Loop. So, look at the Sessions and SQLs and
Execution Plans.
Cloned Buffers :
Buffers are “cloned” when different sessions require different versions for Read
Consistency.
Assume User “A” started a query at time t0
Assume User “C” modified Buffer 123 (representing a specific table block) at
time t5 with an UPDATE statement
If User “A”s session comes to the the same table block, the DBA
(DataBlockAddress) requires it read Buffer 123. It finds, from the Buffer Header
SCN, that the Block has been modified. The ITL entry identifies the Undo
Segment and slot. From the Undo information, the session now as to recreate
the “pre-change” image of the block. So, it “clones” the Buffer as another
Buffer in memory and applies the Undo information to it – because it actually
has to modify the block, which it cannot [and should not] do against the “dirty”
Buffer 123 last updated by User “C”.
The same buffer can have multiple clones. Also, a session might have to keep
“rolling back” a block through multiple updates to get to it’s desired state (SCN).
So : A Buffer Cache of 800MB doesn’t necessarily mean that you have 800MB
of data, some of it could be multiple copies of the same database block, as of
different points in time.
Cache Buffers LRU Chain Latch :
The LRU Chain is a list of buffers. Oracle maintains multiple lists.
A process that needs to load a block into memory “walks” the chain to identify
a buffer that can be “used” (e.g. an empty or clean buffer). If it cannot find a
buffer, it marks a list of dirty buffers for DBWR to flush to disk. When the
buffers are flushed to disk, they are marked “clean” and can be reused. This
latch is required whenever changes are to be made.
Waits on these would mean that DBWR isn’t fast enough.
Learnings :
1. Frequent Hard Parses strain the Shared Pool and Library Cache Latches.
2. Hot Blocks cause waits on particular Cache Buffer Chains Latches. The
Hot Blocks need to be identified based the SQLs of the Sessions waiting
on CBC Latches. Fixes could be SQL tuning, rebuilding table/index,
reverse key indexes(avoid them !!).
3. Move to faster I/O, use Async I/O , add DB_WRITER_PROCESSES only
as a last resort.
4. Latch Issues point to Concurrency issues.
Enqueues
• Imagine a Bank with one Teller
• All Customers who walk in have to form an orderly Queue at the Teller counter
• When the Teller is processing Mr A’s withdrawal request, B, C and D form a queue
behind him.
• The Teller make take 1minute to handle Mr A’s request at the end of which B can
step forward.
• The Teller make take 2.5minutes to handle Mr B’s request. C and D have to wait
patiently in the queue.
• If 5 users are attempting to update the same row in the Buffer, they *have* to access
it in chronological (SCN) order.
• The second user cannot update the row until and unless the first user has issued a
COMMIT or ROLLBACK.
• Enqueues on rows are in the ITL entries within the DataBlock (now a Buffer in
memory).
• If 5 users are updating different rows in the Block (Buffer), each has a separate ITL
entry in the Block, the 5 row locks are “concurrent”.
Enqueues
• The most famous Enqueues are Row Locks
(“TX”) and DML Locks (“TM”)
• DML Locks prevent changes to the structure of
the object being locked.
• Thus a Transaction has Row Locks on Rows
being updated and DML Locks on the Table to
prevent any ALTER commands from modifying
the structure (e.g. add/drop columns) of the
Table
• There are 64 different types of Enqueues (11.2) [62 in 10.2] See Appendix D of the
Reference Guide
The Controlfile (CF) Enqueue is taken when LGWR or ARCH is updating the
Controlfile or when CKPT is updating checkpoint information. NOLOGGING
operations also take CF enqueues !
I’ve seen database instances crash when the CF enqueue is held for too long
by one background process. RMAN uses a snapshot controlfile to avoid CF
enqeuues.
The Undo Segment (US) Enqueue is taken when adding undo segments,
taking them online or offline. When a “storm” of activity occurs, you may find
US enqueue waits.
The Space Transaction (ST) Enqueue is for allocation / deallocation of extents.
The Object Chekpoint (KO) Enqueue is for Oracle to checkpoint an
object/segment – e.g. for a TRUNCATE or DROP or before Parallel Query
The Sequence Number (SQ) Enqueue is for incrementing Sequences. Setting
appropriate CACHE sizes is important.
The Job Queue (JQ) Enqueue is for Jobs.
Cross Instance (CI) Enqueue doesn’t appear only in RAC ! You will see
requests and waits in non-RAC as well.
Enqueue Waits in an *idle* instance :
SQL> desc v$enqueue_stat
Name Null? Type
----------------------------- -------- --------------------
INST_ID NUMBER
EQ_TYPE VARCHAR2(2)
TOTAL_REQ# NUMBER
TOTAL_WAIT# NUMBER
SUCC_REQ# NUMBER
FAILED_REQ# NUMBER
CUM_WAIT_TIME NUMBER
SQL> select eq_type, total_req#, total_wait#
SQL> from v$enqueue_stat where total_wait# > 0 order by 1;
EQ TOTAL_REQ# TOTAL_WAIT#
-- ---------- -----------
CF 2895 1 -- controlfile
JS 64043 15 -- not documented
KO 18 1 -- multiple object checkpoint
PR 358 3 -- process startup
PV 53 3 -- not documented
TH 361 1 -- not documented
6 rows selected.
SQL>
After running :
SQL> create table abc as select * from dba_objects
2 union all select * from dba_objects
3 union all select * from dba_objects;
Table created.
EQ TOTAL_REQ# TOTAL_WAIT#
-- ---------- -----------
KO 27 2
On running :
SQL> select /*+ PARALLEL (a 4) */ count(*) from abc a;
COUNT(*)
----------
229848
SQL>
EQ TOTAL_REQ# TOTAL_WAIT#
-- ---------- -----------
KO 36 3
Learnings :
1. There are many different points of serialisation other than Row Locks.
2. Watch out for critical enqueues – CF, TS, SQ, KO.

More Related Content

What's hot

Oracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New FeaturesOracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New Features
Alex Zaballa
 
Oracle Linux and Oracle Database - A Trusted Combination
Oracle Linux and Oracle Database - A Trusted Combination Oracle Linux and Oracle Database - A Trusted Combination
Oracle Linux and Oracle Database - A Trusted Combination
Guatemala User Group
 
Summary tables with flexviews
Summary tables with flexviewsSummary tables with flexviews
Summary tables with flexviews
Justin Swanhart
 
Oracle Exadata Maintenance tasks 101 - OTN Tour 2015
Oracle Exadata Maintenance tasks 101 - OTN Tour 2015Oracle Exadata Maintenance tasks 101 - OTN Tour 2015
Oracle Exadata Maintenance tasks 101 - OTN Tour 2015
Nelson Calero
 
Crating a Robust Performance Strategy
Crating a Robust Performance StrategyCrating a Robust Performance Strategy
Crating a Robust Performance Strategy
Guatemala User Group
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
Alex Zaballa
 
DOAG - Oracle Database Locking Mechanism Demystified
DOAG - Oracle Database Locking Mechanism Demystified DOAG - Oracle Database Locking Mechanism Demystified
DOAG - Oracle Database Locking Mechanism Demystified
Pini Dibask
 
AUSOUG Oracle Password Security
AUSOUG Oracle Password SecurityAUSOUG Oracle Password Security
AUSOUG Oracle Password Security
Stefan Oehrli
 
GLOC 2014 NEOOUG - Oracle Database 12c New Features
GLOC 2014 NEOOUG - Oracle Database 12c New FeaturesGLOC 2014 NEOOUG - Oracle Database 12c New Features
GLOC 2014 NEOOUG - Oracle Database 12c New Features
Biju Thomas
 
Oracle Cloud As Services
Oracle Cloud As ServicesOracle Cloud As Services
Oracle Cloud As Services
Özgür Umut Vurgun
 
Cloug Troubleshooting Oracle 11g Rac 101 Tips And Tricks
Cloug Troubleshooting Oracle 11g Rac 101 Tips And TricksCloug Troubleshooting Oracle 11g Rac 101 Tips And Tricks
Cloug Troubleshooting Oracle 11g Rac 101 Tips And Tricks
Scott Jenner
 
Oracle GoldenGate
Oracle GoldenGateOracle GoldenGate
Oracle GoldenGate
Anar Godjaev
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
Alex Zaballa
 
Data Tracking: On the Hunt for Information about Your Database
Data Tracking: On the Hunt for Information about Your DatabaseData Tracking: On the Hunt for Information about Your Database
Data Tracking: On the Hunt for Information about Your Database
Michael Rosenblum
 
Advanced Oracle Troubleshooting
Advanced Oracle TroubleshootingAdvanced Oracle Troubleshooting
Advanced Oracle Troubleshooting
Hector Martinez
 
Drilling Deep Into Exadata Performance
Drilling Deep Into Exadata PerformanceDrilling Deep Into Exadata Performance
Drilling Deep Into Exadata Performance
Enkitec
 
Dbvisit replicate: logical replication made easy
Dbvisit replicate: logical replication made easyDbvisit replicate: logical replication made easy
Dbvisit replicate: logical replication made easy
Franck Pachot
 
12 Things about Oracle WebLogic Server 12c
12 Things	 about Oracle WebLogic Server 12c12 Things	 about Oracle WebLogic Server 12c
12 Things about Oracle WebLogic Server 12c
Guatemala User Group
 
10 ways to improve your rman script
10 ways to improve your rman script10 ways to improve your rman script
10 ways to improve your rman script
Maris Elsins
 
Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014
Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014
Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014
Alex Zaballa
 

What's hot (20)

Oracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New FeaturesOracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New Features
 
Oracle Linux and Oracle Database - A Trusted Combination
Oracle Linux and Oracle Database - A Trusted Combination Oracle Linux and Oracle Database - A Trusted Combination
Oracle Linux and Oracle Database - A Trusted Combination
 
Summary tables with flexviews
Summary tables with flexviewsSummary tables with flexviews
Summary tables with flexviews
 
Oracle Exadata Maintenance tasks 101 - OTN Tour 2015
Oracle Exadata Maintenance tasks 101 - OTN Tour 2015Oracle Exadata Maintenance tasks 101 - OTN Tour 2015
Oracle Exadata Maintenance tasks 101 - OTN Tour 2015
 
Crating a Robust Performance Strategy
Crating a Robust Performance StrategyCrating a Robust Performance Strategy
Crating a Robust Performance Strategy
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
DOAG - Oracle Database Locking Mechanism Demystified
DOAG - Oracle Database Locking Mechanism Demystified DOAG - Oracle Database Locking Mechanism Demystified
DOAG - Oracle Database Locking Mechanism Demystified
 
AUSOUG Oracle Password Security
AUSOUG Oracle Password SecurityAUSOUG Oracle Password Security
AUSOUG Oracle Password Security
 
GLOC 2014 NEOOUG - Oracle Database 12c New Features
GLOC 2014 NEOOUG - Oracle Database 12c New FeaturesGLOC 2014 NEOOUG - Oracle Database 12c New Features
GLOC 2014 NEOOUG - Oracle Database 12c New Features
 
Oracle Cloud As Services
Oracle Cloud As ServicesOracle Cloud As Services
Oracle Cloud As Services
 
Cloug Troubleshooting Oracle 11g Rac 101 Tips And Tricks
Cloug Troubleshooting Oracle 11g Rac 101 Tips And TricksCloug Troubleshooting Oracle 11g Rac 101 Tips And Tricks
Cloug Troubleshooting Oracle 11g Rac 101 Tips And Tricks
 
Oracle GoldenGate
Oracle GoldenGateOracle GoldenGate
Oracle GoldenGate
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
Data Tracking: On the Hunt for Information about Your Database
Data Tracking: On the Hunt for Information about Your DatabaseData Tracking: On the Hunt for Information about Your Database
Data Tracking: On the Hunt for Information about Your Database
 
Advanced Oracle Troubleshooting
Advanced Oracle TroubleshootingAdvanced Oracle Troubleshooting
Advanced Oracle Troubleshooting
 
Drilling Deep Into Exadata Performance
Drilling Deep Into Exadata PerformanceDrilling Deep Into Exadata Performance
Drilling Deep Into Exadata Performance
 
Dbvisit replicate: logical replication made easy
Dbvisit replicate: logical replication made easyDbvisit replicate: logical replication made easy
Dbvisit replicate: logical replication made easy
 
12 Things about Oracle WebLogic Server 12c
12 Things	 about Oracle WebLogic Server 12c12 Things	 about Oracle WebLogic Server 12c
12 Things about Oracle WebLogic Server 12c
 
10 ways to improve your rman script
10 ways to improve your rman script10 ways to improve your rman script
10 ways to improve your rman script
 
Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014
Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014
Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014
 

Viewers also liked

Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning Fundamentals
Carlos Sierra
 
Oracle database performance tuning
Oracle database performance tuningOracle database performance tuning
Oracle database performance tuning
Yogiji Creations
 
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And WhatPerformance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
udaymoogala
 
Oracle Architecture
Oracle ArchitectureOracle Architecture
Oracle Architecture
Neeraj Singh
 
Oracle Basics and Architecture
Oracle Basics and ArchitectureOracle Basics and Architecture
Oracle Basics and Architecture
Sidney Chen
 
Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)
Guy Harrison
 

Viewers also liked (6)

Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning Fundamentals
 
Oracle database performance tuning
Oracle database performance tuningOracle database performance tuning
Oracle database performance tuning
 
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And WhatPerformance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
 
Oracle Architecture
Oracle ArchitectureOracle Architecture
Oracle Architecture
 
Oracle Basics and Architecture
Oracle Basics and ArchitectureOracle Basics and Architecture
Oracle Basics and Architecture
 
Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)
 

Similar to Oracle Diagnostics : Latches and Enqueues

Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
Bob Pusateri
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
Bob Pusateri
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
Bob Pusateri
 
SQLBits XIV - The Big Backup Theory
SQLBits XIV - The Big Backup TheorySQLBits XIV - The Big Backup Theory
SQLBits XIV - The Big Backup Theory
Richard Douglas
 
01 oracle architecture
01 oracle architecture01 oracle architecture
01 oracle architecture
Smitha Padmanabhan
 
Top 20 FAQs on the Autonomous Database
Top 20 FAQs on the Autonomous DatabaseTop 20 FAQs on the Autonomous Database
Top 20 FAQs on the Autonomous Database
Sandesh Rao
 
Hekaton introduction for .Net developers
Hekaton introduction for .Net developersHekaton introduction for .Net developers
Hekaton introduction for .Net developers
Shy Engelberg
 
Building and Running Solr-as-a-Service: Presented by Shai Erera, IBM
Building and Running Solr-as-a-Service: Presented by Shai Erera, IBMBuilding and Running Solr-as-a-Service: Presented by Shai Erera, IBM
Building and Running Solr-as-a-Service: Presented by Shai Erera, IBM
Lucidworks
 
Presentation day4 oracle12c
Presentation day4 oracle12cPresentation day4 oracle12c
Presentation day4 oracle12c
Pradeep Srivastava
 
An Introduction To Oracle Database
An Introduction To Oracle DatabaseAn Introduction To Oracle Database
An Introduction To Oracle Database
Meysam Javadi
 
Using Release(deallocate) and Painful Lessons to be learned on DB2 locking
Using Release(deallocate) and Painful Lessons to be learned on DB2 lockingUsing Release(deallocate) and Painful Lessons to be learned on DB2 locking
Using Release(deallocate) and Painful Lessons to be learned on DB2 locking
John Campbell
 
backgroundcommunicationandwaitevents-180124221026.pdf
backgroundcommunicationandwaitevents-180124221026.pdfbackgroundcommunicationandwaitevents-180124221026.pdf
backgroundcommunicationandwaitevents-180124221026.pdf
ssuser785ce21
 
SQL Server In-Memory OLTP introduction (Hekaton)
SQL Server In-Memory OLTP introduction (Hekaton)SQL Server In-Memory OLTP introduction (Hekaton)
SQL Server In-Memory OLTP introduction (Hekaton)
Shy Engelberg
 
SQL Server Wait Types Everyone Should Know
SQL Server Wait Types Everyone Should KnowSQL Server Wait Types Everyone Should Know
SQL Server Wait Types Everyone Should Know
Dean Richards
 
L6.sp17.pptx
L6.sp17.pptxL6.sp17.pptx
L6.sp17.pptx
SudheerKumar499932
 
Inside sql server in memory oltp sql sat nyc 2017
Inside sql server in memory oltp sql sat nyc 2017Inside sql server in memory oltp sql sat nyc 2017
Inside sql server in memory oltp sql sat nyc 2017
Bob Ward
 
Cassandra Tutorial
Cassandra Tutorial Cassandra Tutorial
Cassandra Tutorial
Na Zhu
 
Oracle 10g Introduction 1
Oracle 10g Introduction 1Oracle 10g Introduction 1
Oracle 10g Introduction 1
Eryk Budi Pratama
 
Sql server-dba
Sql server-dbaSql server-dba
Sql server-dba
NaviSoft
 
Database architectureby howard
Database architectureby howardDatabase architectureby howard
Database architectureby howard
oracle documents
 

Similar to Oracle Diagnostics : Latches and Enqueues (20)

Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
 
SQLBits XIV - The Big Backup Theory
SQLBits XIV - The Big Backup TheorySQLBits XIV - The Big Backup Theory
SQLBits XIV - The Big Backup Theory
 
01 oracle architecture
01 oracle architecture01 oracle architecture
01 oracle architecture
 
Top 20 FAQs on the Autonomous Database
Top 20 FAQs on the Autonomous DatabaseTop 20 FAQs on the Autonomous Database
Top 20 FAQs on the Autonomous Database
 
Hekaton introduction for .Net developers
Hekaton introduction for .Net developersHekaton introduction for .Net developers
Hekaton introduction for .Net developers
 
Building and Running Solr-as-a-Service: Presented by Shai Erera, IBM
Building and Running Solr-as-a-Service: Presented by Shai Erera, IBMBuilding and Running Solr-as-a-Service: Presented by Shai Erera, IBM
Building and Running Solr-as-a-Service: Presented by Shai Erera, IBM
 
Presentation day4 oracle12c
Presentation day4 oracle12cPresentation day4 oracle12c
Presentation day4 oracle12c
 
An Introduction To Oracle Database
An Introduction To Oracle DatabaseAn Introduction To Oracle Database
An Introduction To Oracle Database
 
Using Release(deallocate) and Painful Lessons to be learned on DB2 locking
Using Release(deallocate) and Painful Lessons to be learned on DB2 lockingUsing Release(deallocate) and Painful Lessons to be learned on DB2 locking
Using Release(deallocate) and Painful Lessons to be learned on DB2 locking
 
backgroundcommunicationandwaitevents-180124221026.pdf
backgroundcommunicationandwaitevents-180124221026.pdfbackgroundcommunicationandwaitevents-180124221026.pdf
backgroundcommunicationandwaitevents-180124221026.pdf
 
SQL Server In-Memory OLTP introduction (Hekaton)
SQL Server In-Memory OLTP introduction (Hekaton)SQL Server In-Memory OLTP introduction (Hekaton)
SQL Server In-Memory OLTP introduction (Hekaton)
 
SQL Server Wait Types Everyone Should Know
SQL Server Wait Types Everyone Should KnowSQL Server Wait Types Everyone Should Know
SQL Server Wait Types Everyone Should Know
 
L6.sp17.pptx
L6.sp17.pptxL6.sp17.pptx
L6.sp17.pptx
 
Inside sql server in memory oltp sql sat nyc 2017
Inside sql server in memory oltp sql sat nyc 2017Inside sql server in memory oltp sql sat nyc 2017
Inside sql server in memory oltp sql sat nyc 2017
 
Cassandra Tutorial
Cassandra Tutorial Cassandra Tutorial
Cassandra Tutorial
 
Oracle 10g Introduction 1
Oracle 10g Introduction 1Oracle 10g Introduction 1
Oracle 10g Introduction 1
 
Sql server-dba
Sql server-dbaSql server-dba
Sql server-dba
 
Database architectureby howard
Database architectureby howardDatabase architectureby howard
Database architectureby howard
 

More from Hemant K Chitale

SQL Tracing
SQL TracingSQL Tracing
SQL Tracing
Hemant K Chitale
 
Oracle : Monitoring and Diagnostics without OEM
Oracle : Monitoring and Diagnostics without OEMOracle : Monitoring and Diagnostics without OEM
Oracle : Monitoring and Diagnostics without OEM
Hemant K Chitale
 
Oracle Diagnostics : Joins - 1
Oracle Diagnostics : Joins - 1Oracle Diagnostics : Joins - 1
Oracle Diagnostics : Joins - 1
Hemant K Chitale
 
Oracle Diagnostics : Explain Plans (Simple)
Oracle Diagnostics : Explain Plans (Simple)Oracle Diagnostics : Explain Plans (Simple)
Oracle Diagnostics : Explain Plans (Simple)
Hemant K Chitale
 
Oracle Diagnostics : Locks and Lock Trees
Oracle Diagnostics :  Locks and Lock TreesOracle Diagnostics :  Locks and Lock Trees
Oracle Diagnostics : Locks and Lock Trees
Hemant K Chitale
 
Partitioning Tables and Indexing Them --- Article
Partitioning Tables and Indexing Them --- ArticlePartitioning Tables and Indexing Them --- Article
Partitioning Tables and Indexing Them --- Article
Hemant K Chitale
 
Oracle database performance diagnostics - before your begin
Oracle database performance diagnostics  - before your beginOracle database performance diagnostics  - before your begin
Oracle database performance diagnostics - before your begin
Hemant K Chitale
 
The role of the dba
The role of the dba The role of the dba
The role of the dba
Hemant K Chitale
 
Partitioning tables and indexing them
Partitioning tables and indexing them Partitioning tables and indexing them
Partitioning tables and indexing them
Hemant K Chitale
 

More from Hemant K Chitale (9)

SQL Tracing
SQL TracingSQL Tracing
SQL Tracing
 
Oracle : Monitoring and Diagnostics without OEM
Oracle : Monitoring and Diagnostics without OEMOracle : Monitoring and Diagnostics without OEM
Oracle : Monitoring and Diagnostics without OEM
 
Oracle Diagnostics : Joins - 1
Oracle Diagnostics : Joins - 1Oracle Diagnostics : Joins - 1
Oracle Diagnostics : Joins - 1
 
Oracle Diagnostics : Explain Plans (Simple)
Oracle Diagnostics : Explain Plans (Simple)Oracle Diagnostics : Explain Plans (Simple)
Oracle Diagnostics : Explain Plans (Simple)
 
Oracle Diagnostics : Locks and Lock Trees
Oracle Diagnostics :  Locks and Lock TreesOracle Diagnostics :  Locks and Lock Trees
Oracle Diagnostics : Locks and Lock Trees
 
Partitioning Tables and Indexing Them --- Article
Partitioning Tables and Indexing Them --- ArticlePartitioning Tables and Indexing Them --- Article
Partitioning Tables and Indexing Them --- Article
 
Oracle database performance diagnostics - before your begin
Oracle database performance diagnostics  - before your beginOracle database performance diagnostics  - before your begin
Oracle database performance diagnostics - before your begin
 
The role of the dba
The role of the dba The role of the dba
The role of the dba
 
Partitioning tables and indexing them
Partitioning tables and indexing them Partitioning tables and indexing them
Partitioning tables and indexing them
 

Recently uploaded

Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
VALiNTRY360
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
gapen1
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
YousufSait3
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
Karya Keeper
 
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
kalichargn70th171
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
ISH Technologies
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.
AnkitaPandya11
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
Rakesh Kumar R
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
Marcin Chrost
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 

Recently uploaded (20)

Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
 
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 

Oracle Diagnostics : Latches and Enqueues

  • 2. Hemant K Chitale • whoami ? • Oracle 5 to Oracle 10gR2 : DOS, Xenix,8 flavours of Unix, Linux, Windows • Financial Services, Govt/Not-for-Profit, ERP, Custom • Production Support, Consulting, Development • A DBA, not a Developer • My Oracle Blog http://hemantoracledba.blogspot.com
  • 3. Latches and Enqueues • Latches are points of concurrency ; Enqueues are points of serialisation. • Three sessions may be waiting on a Latch – any of the three may get the Latch before the other two. • If sessions are waiting on an Enqueue, access is serialised – the first session to start waiting gets the Enqueue first.
  • 4. Latches • Imagine a Wishing Well with place for only 1 person to stand in front of it • Four persons approach the Wishing Well almost “simultaneously” • Mr A gets to the well first and stands before it making his wish before dropping a coin • The other three persons (B, C and D) loiter around. B wanders off to look at garden, C sits down on a bench and D stands close to A. REMEMBER : There is no convention that people must queue at a Wishing Well. • A takes a long time making his wish and D get’s bored (his process has hit the “spin count” limit for the number of No-Op spins it can do on the CPU) and wanders away. He relinquishes his place. • When A finishes and walks away, C rushes forward and get’s to the well first. • In the meantime, E and F have also walked in on the scene. • After C, D gets to the well. • Before B can get back, E is next in making a wish at the well
  • 5. Latches • There you have it ! • There is no “sequencing” or “ordering”. • A process may spin on the CPU waiting for a Latch but if it doesn’t get the latch, it relinquishes the CPU and goes to “sleep”. • It may not be the first process to get the Latch when it is released – some other process happens to be lucky enough to get the Latch. • Latches protect access to Memory Resources. • A datablock for a table is loaded into the SGA as a Buffer. It may contain 20 different rows. • If 5 users need access to 5 different rows in that Buffer, they may get access to modify the Buffer in any order. Oracle really doesn’t care which of the 5 users modify the Buffer first --- as long as they are not modifying the same rows. • Latches on Buffers are in the Headers that are on the Cache Buffers Chain lists – in- memory linked lists.
  • 6. Latches Diagnosis - 1 • Identify Latches with V$LATCHNAME, V$LATCH, V$LATCH_PARENT, V$LATCH_CHILDREN • Latch Holders are in V$LATCHHOLDER • Latches may be “willing-to-wait” and “no- wait” latches
  • 7. Latches Diagnosis - 2 • Statistics are presented “gets”, “misses” and “sleeps” – 1,2,3… where the session sleeps once or twice or thrice or four or more times, because it was unable to “get” the latch each time it awoke from it’s sleep • Most commonly known latches : – library cache ; shared pool – cache buffers chains
  • 8. Identifying Latches (listing from 11.2) : SQL> select count(*) from v$latchname; COUNT(*) ---------- 535 SQL> select count(*) from v$latch; COUNT(*) ---------- 535 SQL> select count(*) from v$latch_parent; COUNT(*) ---------- 535 SQL> select count(*) from v$latch_children; COUNT(*) ---------- 2773 SQL> SQL> desc v$latchholder Name Null? Type ----------------------------------------- -------- ---------------------------- PID NUMBER SID NUMBER LADDR RAW(4) NAME VARCHAR2(64) GETS NUMBER SQL>
  • 9. Library Cache Latch usage : This latch protects SQL statements, object definitions etc. Oracle internally determines the number of latches available (as a prime number). Adding new SQL statements and Objects require the Latch. One latch would be protecting multiple SQLs. Note : If you have DDLs modifying object definitions, there would be waits on the Library Cache Latches protecting those objects. Library Cache Pin Latch usage : When a statement is re-executed (it has to be pinned to ensure that it is not modified ! Shared Pool Latch : This latch protects the allocation of memory in the Shared Pool. Multiple child latches are created. Frequent Hard Parsing of SQLs would cause frequent access to the Shared Pool Latch.
  • 10. Cache Buffers Chains Latch : Protects Memory Buffers for Database Blocks. Multiple (Child) Latches are present, each Latch protecting multiple buffers (blocks). Blocks are loaded into memory based on a hash of the Database Block Address. A Linked List of the Buffer Headers is maintained so that a Block can be found quickly in the Buffer Cache. Look for CBC Latches with very high SLEEPs – indicating very frequent retries. Don’t run this query – it will take a long time on a busy instance / large database. -- query from How To Identify a Hot Block Within The Database Buffer Cache. [ID 163424.1] select /*+ RULE */ e.owner ||'.'|| e.segment_name segment_name, e.extent_id extent#, x.dbablk - e.block_id + 1 block#, x.tch, l.child# from sys.v$latch_children l, sys.x$bh x, sys.dba_extents e where x.hladdr = '&ADDR' and e.file_id = x.file# and x.hladdr = l.addr and x.dbablk between e.block_id and e.block_id + e.blocks -1 order by x.tch desc ; Typically Hot Blocks can be Index Root / Branch Blocks when an Index is frequently used in a Nested Loop. So, look at the Sessions and SQLs and Execution Plans.
  • 11. Cloned Buffers : Buffers are “cloned” when different sessions require different versions for Read Consistency. Assume User “A” started a query at time t0 Assume User “C” modified Buffer 123 (representing a specific table block) at time t5 with an UPDATE statement If User “A”s session comes to the the same table block, the DBA (DataBlockAddress) requires it read Buffer 123. It finds, from the Buffer Header SCN, that the Block has been modified. The ITL entry identifies the Undo Segment and slot. From the Undo information, the session now as to recreate the “pre-change” image of the block. So, it “clones” the Buffer as another Buffer in memory and applies the Undo information to it – because it actually has to modify the block, which it cannot [and should not] do against the “dirty” Buffer 123 last updated by User “C”. The same buffer can have multiple clones. Also, a session might have to keep “rolling back” a block through multiple updates to get to it’s desired state (SCN). So : A Buffer Cache of 800MB doesn’t necessarily mean that you have 800MB of data, some of it could be multiple copies of the same database block, as of different points in time.
  • 12. Cache Buffers LRU Chain Latch : The LRU Chain is a list of buffers. Oracle maintains multiple lists. A process that needs to load a block into memory “walks” the chain to identify a buffer that can be “used” (e.g. an empty or clean buffer). If it cannot find a buffer, it marks a list of dirty buffers for DBWR to flush to disk. When the buffers are flushed to disk, they are marked “clean” and can be reused. This latch is required whenever changes are to be made. Waits on these would mean that DBWR isn’t fast enough.
  • 13. Learnings : 1. Frequent Hard Parses strain the Shared Pool and Library Cache Latches. 2. Hot Blocks cause waits on particular Cache Buffer Chains Latches. The Hot Blocks need to be identified based the SQLs of the Sessions waiting on CBC Latches. Fixes could be SQL tuning, rebuilding table/index, reverse key indexes(avoid them !!). 3. Move to faster I/O, use Async I/O , add DB_WRITER_PROCESSES only as a last resort. 4. Latch Issues point to Concurrency issues.
  • 14. Enqueues • Imagine a Bank with one Teller • All Customers who walk in have to form an orderly Queue at the Teller counter • When the Teller is processing Mr A’s withdrawal request, B, C and D form a queue behind him. • The Teller make take 1minute to handle Mr A’s request at the end of which B can step forward. • The Teller make take 2.5minutes to handle Mr B’s request. C and D have to wait patiently in the queue. • If 5 users are attempting to update the same row in the Buffer, they *have* to access it in chronological (SCN) order. • The second user cannot update the row until and unless the first user has issued a COMMIT or ROLLBACK. • Enqueues on rows are in the ITL entries within the DataBlock (now a Buffer in memory). • If 5 users are updating different rows in the Block (Buffer), each has a separate ITL entry in the Block, the 5 row locks are “concurrent”.
  • 15. Enqueues • The most famous Enqueues are Row Locks (“TX”) and DML Locks (“TM”) • DML Locks prevent changes to the structure of the object being locked. • Thus a Transaction has Row Locks on Rows being updated and DML Locks on the Table to prevent any ALTER commands from modifying the structure (e.g. add/drop columns) of the Table • There are 64 different types of Enqueues (11.2) [62 in 10.2] See Appendix D of the Reference Guide
  • 16. The Controlfile (CF) Enqueue is taken when LGWR or ARCH is updating the Controlfile or when CKPT is updating checkpoint information. NOLOGGING operations also take CF enqueues ! I’ve seen database instances crash when the CF enqueue is held for too long by one background process. RMAN uses a snapshot controlfile to avoid CF enqeuues. The Undo Segment (US) Enqueue is taken when adding undo segments, taking them online or offline. When a “storm” of activity occurs, you may find US enqueue waits. The Space Transaction (ST) Enqueue is for allocation / deallocation of extents. The Object Chekpoint (KO) Enqueue is for Oracle to checkpoint an object/segment – e.g. for a TRUNCATE or DROP or before Parallel Query The Sequence Number (SQ) Enqueue is for incrementing Sequences. Setting appropriate CACHE sizes is important. The Job Queue (JQ) Enqueue is for Jobs. Cross Instance (CI) Enqueue doesn’t appear only in RAC ! You will see requests and waits in non-RAC as well.
  • 17. Enqueue Waits in an *idle* instance : SQL> desc v$enqueue_stat Name Null? Type ----------------------------- -------- -------------------- INST_ID NUMBER EQ_TYPE VARCHAR2(2) TOTAL_REQ# NUMBER TOTAL_WAIT# NUMBER SUCC_REQ# NUMBER FAILED_REQ# NUMBER CUM_WAIT_TIME NUMBER SQL> select eq_type, total_req#, total_wait# SQL> from v$enqueue_stat where total_wait# > 0 order by 1; EQ TOTAL_REQ# TOTAL_WAIT# -- ---------- ----------- CF 2895 1 -- controlfile JS 64043 15 -- not documented KO 18 1 -- multiple object checkpoint PR 358 3 -- process startup PV 53 3 -- not documented TH 361 1 -- not documented 6 rows selected. SQL>
  • 18. After running : SQL> create table abc as select * from dba_objects 2 union all select * from dba_objects 3 union all select * from dba_objects; Table created. EQ TOTAL_REQ# TOTAL_WAIT# -- ---------- ----------- KO 27 2 On running : SQL> select /*+ PARALLEL (a 4) */ count(*) from abc a; COUNT(*) ---------- 229848 SQL> EQ TOTAL_REQ# TOTAL_WAIT# -- ---------- ----------- KO 36 3
  • 19. Learnings : 1. There are many different points of serialisation other than Row Locks. 2. Watch out for critical enqueues – CF, TS, SQ, KO.