Last update (2011-04-28 16:32:01)
                                                                                                                   Date added (2008-05-29 12:02:09)

What Are Latches?
Latches are serialization mechanisms that protect areas of Oracle's shared memory (the SGA). In simple terms, latches prevent two processes from simultaneously updating — and possibly corrupting — the same area of the SGA.

How Latches Work
The latching mechanism is very lightweight and the duration of operations against memory is very small (typically in the order of nanoseconds), but because of the high frequency for latch requests is CPU consuming procedure.

If the latch is already in use, Oracle can assume that it will not be in use for long, so rather than go into a passive wait (e.g., relinquish the CPU and go to sleep) Oracle will retry the operation a number of times before giving up and going to passive wait.

The first time the session fails to acquire the latch by spinning, it will attempt to awaken after 10 milliseconds. Subsequent waits will increase in duration and in extreme circumstances may exceed one second. In a system suffering from intense contention for latches, these waits will have a severe impact on response time and throughput.

So contention for latches equals to CPU resource consumption.

Causes of contention for specific latches
The latches that most frequently affect performance are those protecting the buffer cache, areas of the shared pool and the redo buffer.

Library cache latches: These latches protect the library cache in which sharable SQL is stored. In a well defined application there should be little or no contention for these latches, but in an application that uses literals instead of bind variables (for instance “WHERE customer='KAPARELIS'” rather that “WHERE customer=:customer,” library cache contention is common.
Redo copy/redo allocation latches: These latches protect the redo log buffer, which buffers entries made to the redo log.
Shared pool latches: These latches are held when allocations or de-allocations of memory occur in the shared pool. Prior to Oracle 8.1.7, the most common cause of shared pool latch contention was an overly large shared pool and/or failure to make use of the reserved area of the shared pool.
Cache buffers chain latches: These latches are held when sessions read or write to buffers in the buffer cache. In Oracle8i, there are typically a very large number of these latches each of which protects only a handful of blocks. Contention on these latches is typically caused by concurrent access to a very “hot” block and the most common type of such a hot block is is an index root or branch block (since any index based query must access the root block).

For more information about Latches you can refer to Metalink Note:34576.1