Understand the Latches, Enqueues and mutexes in Oracle

Understand the Latches, Enqueues and mutexes in Oracle

Latches
Latches are low level serialization mechanism used to protect shared data structures in the SGA.
It is used to prevent more than one process from executing the same piece of code at a given time.
Its depend upon the operating system, whether a process will wait for a latch and for how long.
This lock is very quickly acquired and freed.
It also has cleanup process if process dies while holding lock. It done by PMON process.
Process acquire a latch when working in SGA. It holds and dropped when process is finished.

Enqueue

Enqueues is another locking mechanism used in oracle . It permits several concurrent processes to have varying degree of sharing the resources.
Concurrently used object , can be protected with enqueues.
Example table allow varying levels of sharing.
Two processes can be locked a table in share mode or in share update mode etc.

Mutexes
Mutexes like latches are a light-weight and more granular concurrency mechanism than latches.
It ensure that certain operations are properly managed for concurrency.
Example if one session is changing a data structure in memory, then another session must wait to acquire the mutexes.

Difference between Latches and Enqueues:

Enqueues is obtained using an OS specific locking mechanism.
Latch is obtained independent of the OS.

Latches there is no ordered queue of waiters.
Enqueues has ordered queue of waiters.

This entry was posted in Oracle on by .
Unknown's avatar

About SandeepSingh

Hi, I am working in IT industry with having more than 15 year of experience, worked as an Oracle DBA with a Company and handling different databases like Oracle, SQL Server , DB2 etc Worked as a Development and Database Administrator.

Leave a Reply