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 


 

 

 


 

 

 
 


How Latches Differ From Locks

Expert Oracle Database Tips by Donald BurlesonMarch 22, 2015

How Latches Differ From Locks

As was mentioned earlier in the chapter, latches differ from locks within Oracle in terms of duration with respect to restricting access to data structures for transactions and processes with the database. Latches are short term in length of operation and locks are long duration in restricting access to Oracle data structures. As such, latches are lightweight serialization and locks are the heavy duty long running serialization mechanism. However, latchesare strict compared to locks in terms of restricting access to data structures within Oracle.

While locks permit shared and concurrent access, latches allow access to only a single process at a time and prevent other processes within Oracle from accessing that process while a latch is held by the process. Latches affect only data structures within the Oracle SGA, whereas locks apply to Oracle transactions. As such, latches affect a more limited scope compared to locks.  Latches also fulfill a single purpose which is to grant exclusive access to Oracle memory structures. Therefore, they control access to the SGA memory data structures for single operations in contrast to locks which serve dual purposes.

Unlike latches, locksand enqueues function to allow multiple processes to share resources when lock modes are compatible as well as to enforce data integrity by restricting access to resources based on lock modes in place for transactions. Latches are limited serialization mechanisms that are non-transactional and only for memory resources in the SGA for Oracle, as mentioned earlier, whereas locks are application driven and control access to database transactions.

Latches also differ from locks in that they can be requested in only two modes: no-wait and willing-to-wait, while locks have six different request modes: null, row share, row exclusive, share row exclusive, share, or exclusive.

Another key difference between latches and locks within Oracle lies in terms of scope of process, memory and transaction management. Latches are visible only to the local instance in memory as opposed to locks which maintain information within the Oracle database and are visible to all of the instances that have access to the database. As such, locks operate at the database level versus latches which are based at the instance level in Oracle memory.

Yet another difference between latches and locks can be explained in how complex both mechanisms are within Oracle. Latches use simple instructions such as simple CPU-based OS instructions and are based on operating system implementations while locks are heavy weight mechanisms that use a series of complex instructions in terms of context switching. 

In addition to the above, differences between latches and locks can explain using duration of operation. Latches are simple, short-lived mechanisms that last in microseconds versus longer held running locks that can last for hours based on the lock mode and transaction held by the lock in question.

Furthermore, locks operate based on a queuing methodology in that for every Oracle process that fails to obtain a lock, the request for the process is placed into a queue and serviced in order unless NOWAIT is specified in the lock request. Latches, on the other hand, do not use any type of queuing mechanism except for the latch wait list latch which does use a queue as part of its algorithm.  For instance, when a specific process within Oracle falls into sleep mode and fails to acquire a latch, the request will not be queued up and serviced in order.

In other words, latches are on a first-come, first grab basis in terms of allocation and management. Because of the way that latches operate within Oracle, they are not affected by deadlocks. Locks, on the other hand, are affected by deadlock conditions. Whenever a deadlock occurs that involves a lock, Oracle generates a trace file with the deadlock error message in the alert log file. Latch waiters, on the other hand, use either timers to wakeup and retry or will spin before retry access to the latch.

 
 
 
Frustrated by the Hidden or Undocumented Features of Oracle? 

The landmark book "Exploring Oracle Internals: Tips and Tricks for the Oracle DBA"  will take you far beyond the standard features of the Oracle database into the hidden and undocumented realms formerly reserved for Oracle insiders.  You will discover valuable tips and tricks for mastering your Oracle database, 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 -  2020

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