Tuesday, July 7, 2009

Oracle Lock and Latch comparison

Oracle uses both lock and latch to protect data integrity and provides concurrency for user processes. But there are a number of differences between lock and latch.

• Lock protects disk data structure and latch protects memory data structure
• Lock is complex data structure and has shared access mode, latch is simple data structure with exclusive mode only
• Lock is slow because it is complex and involves disk operation, latch is fast because it is simple and memory operation only.
• Lock is queued so dead lock is possible. Latch is hit and run that uses spin and sleep for waiting.
• Lock is not needed for read because of Oracle’s multiversion concurrency control (MVCC), latch is needed for all data access in memory, including read.

No comments:

Post a Comment