Master in Oracle Cloud (OCI) | Join us for the demo session on 2nd December 2025 at 7:00 PM IST

Understanding Latches, Locks & Enqueues in Oracle

Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
  • User AvatarPradip
  • 28 Nov, 2025
  • 0 Comments
  • 3 Mins Read

Understanding Latches, Locks & Enqueues in Oracle

Understanding Latches, Locks & Enqueues in Oracle (Complete Guide for DBAs)

When multiple users access data simultaneously, Oracle uses different concurrency control mechanisms to maintain data consistency, transaction isolation, and instance stability.
Among these mechanisms, latches, locks, and enqueues are the most important — yet often the most confusing for new DBAs.


1. What Are Latches in Oracle?

Latches are low-level serialization mechanisms used to protect in-memory shared data structures in the SGA.

Think of a latch as a very fast, short-duration lock used internally by Oracle.

Key Characteristics

  • Lightweight and in-memory

  • Very fast (microseconds)

  • Not transactional

  • Held for a very short time

  • Protect shared memory structures (e.g., library cache, buffer cache)

Real-World Example

When multiple sessions try to read or write from the buffer cache, Oracle uses buffer cache latches to avoid corruption.

Common Latch Contention Symptoms

  • High CPU usage

  • Library Cache: Pin or Lock latch waits

  • Query execution delays

Useful Views

SELECT * FROM v$latch;
SELECT * FROM v$latchholder;
SELECT * FROM v$latchname;

Latches = Speed + Protection (not related to user transactions)


2. What Are Locks in Oracle?

Locks are used to control access to data in the database and maintain transaction isolation.

These are DML locks that ensure two users don’t change the same data at the same time.

Key Characteristics

  • Protect rows, tables, and objects

  • Held for the duration of a transaction

  • Enforce data consistency

  • Acquired automatically by Oracle

Example

Session A updates a row:

UPDATE employees SET salary = 50000 WHERE id = 100;

Session B tries to update the same row → row lock wait.

Types of Locks

  • Row-level locks (TX)

  • Table locks (TM)

  • DDL locks

  • Internal locks

Useful Views

SELECT * FROM v$lock;
SELECT * FROM dba_blockers;
SELECT * FROM dba_waiters;

Locks = Protecting data during transactions


3. What Are Enqueues in Oracle?

Enqueues are more advanced, flexible locking mechanisms that follow a queue structure — hence the name “enqueue”.

They are used for transactional locks, schema locks, and inter-instance coordination (RAC).

Key Characteristics

  • Follow a queue mechanism

  • Can be held in different modes (NULL, Share, Exclusive, etc.)

  • Can persist for longer periods

  • Protects multiple database resources

Example

  • When a session updates a row → TX enqueue

  • When a session executes DDL → TM enqueue

Common Enqueue Types

Enqueue Type Meaning
TX Transaction lock
TM DML enqueue (table)
CF Control file enqueue
HW High watermark enqueue
SQ Sequence number enqueue

 

Useful View

SELECT sid, type, id1, id2, lmode, request FROM v$lock WHERE type IN ('TX','TM');

Enqueues = Structured, queued locks for multiple resource types


4. Latches vs Locks vs Enqueues (Quick Comparison)

Feature Latches Locks Enqueues
Purpose Protect memory structures Protect data Protect various DB resources
Duration Microseconds Until commit/rollback Varies
Type Internal, low-level DML DDL + DML + Internal
Waits Seen In CPU, library cache Row lock waits TX/TM wait events
Mechanism Spin + sleep Queue Queue based

Simple Explanation:

  • Latches → Protect RAM

  • Locks → Protect Data

  • Enqueues → Protect Resources


5. Common Wait Events Related to Each

Latch Waits

  • latch: library cache

  • latch: shared pool

Lock Waits

  • enq: TX - row lock contention

  • enq: TM - contention

Enqueue Waits

  • enq: TM – contention

  • enq: HW – contention

  • enq: CF – contention


6. How to Diagnose Contention

 Check Blocking and Waiting Sessions

SELECT * FROM v$session WHERE blocking_session IS NOT NULL;

 Find the Object Causing Lock

SELECT * FROM dba_objects WHERE object_id = <ID>;

 Kill a Blocking Session

ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;

Conclusion

Understanding the difference between latches, locks, and enqueues is essential for any Oracle DBA.
They help keep the database consistent, stable, and performant, even when thousands of sessions are running concurrently.

Explore more with Learnomate Technologies!

Want to see how we teach?
Head over to our YouTube channel for insights, tutorials, and tech breakdowns:
👉 www.youtube.com/@learnomate

To know more about our courses, offerings, and team:
Visit our official website:
👉 www.learnomate.org

Interested in mastering Oracle Database Administration?
Check out our comprehensive Oracle DBA Training program here:
👉 https://learnomate.org/oracle-dba-training/

Want to explore more tech topics?
Check out our detailed blog posts here:
👉 https://learnomate.org/blogs/

And hey, I’d love to stay connected with you personally!
🔗 Let’s connect on LinkedIn: Ankush Thavali 😎

Let's Talk

Find your desired career path with us!

Let's Talk

Find your desired career path with us!