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. A latch is a type of a lock that can be very quickly
acquired and freed. Latches are typically used to prevent more than one
process from executing the same piece of code at a
Oracle sessions need to update or read from the SGA for almost all
database operations. For instance:
When a session reads a block from disk, it must modify a free block
in the buffer cache and adjust the buffer cache LRU chain
- When a session reads a block from the SGA, it will modify the LRU
When a new SQL statement is parsed, it will be added to the library
cache within the SGA.
- As modifications are made to blocks, entries are placed in the redo
- The database writer periodically writes buffers from the cache to
disk (and must update their status from “dirty” to “clean”).
- The redo log writer writes entries from the redo buffer to the redo
Latches prevent any of these operations from colliding and possibly
corrupting the SGA.