Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Oracle Row Locks and Row Level Locking

Oracle Database Tips by Burleson Consulting

June 14, 2015

Question:  How does row level locking work in Oracle?

Answer:  When a transaction begins it opens an exclusive lock on a resource.  The name of the lock depends on the transaction ID for the freshly started transaction.  This resource then, if requested by another transaction, will serve as a wait point until the transaction holding the lock performs either a commit or a rollback. 

For example, assume we have two transactions, each requesting the same resource.  The first transaction accesses the resource and generates a lock.  The second transaction will detect that the resource it is trying to access is locked by the first transaction, and would then request a lock in exclusive mode, on the resource.  When the first transaction commits or performs a rollback, it will release the exclusive lock on the resource.  When the lock is released, the second transaction gains an exclusive lock and proceeds.

This is a step by step look at the row locking mechanism:

  1. Transaction begins either implicitly via any DML, or explicitly via  set transaction.
  2. A slot is allocated in the rollback segment header.  This slot is allocated either via a round robin selection process, or specified by the set transaction use rollback segment ...  statement.
  3. Blocks to be changed are identifired using the execution plan, utilizing whatever access paths are specified there.
  4. The transaction looks for an empty slot on the Interested Transaction List (ITL).  If there are none available, one will be allocated from free space in the block if it is available.  If that fails, the transaction will wait on a TX enqueue in mode 4.  When the ITL slot has been allocated, it will point to the rollback segment header that was previously reserved by the transaction.
  5. When the ITL slot is allocated in the block, specific rows are marked as locked in the row directory.  The lock byte will be set to point to the ITL slot held by the transaction.  This is the mechanism that acutally maintains the row-level locks in Oracle.  Once the lock byte is set, the row can be operated on.  If changes to the block are made, the before images are recorded in the rollback segment reserved by the transaction.
  6. When a commit or rollback is performed, the lock is released.  When a commit occurs, in order to release the lock, the rollback segment header slot must be marked as committed.  Cleanup of the block itself is usually delayed until a later time.


 
Get the Complete
Oracle SQL Tuning Information 

The landmark book "Advanced Oracle SQL Tuning  The Definitive Reference"  is filled with valuable information on Oracle SQL Tuning. This book includes scripts and tools to hypercharge Oracle 11g performance and you can buy it for 30% off directly from the publisher.

 


 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2016

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.


 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster