Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Chapter 16 Latch and Mutex Contention. 2 Architecture Overview of Latches Protect Oracle’s SGA Prevent two processes from updating same area of SGA.

Similar presentations


Presentation on theme: "1 Chapter 16 Latch and Mutex Contention. 2 Architecture Overview of Latches Protect Oracle’s SGA Prevent two processes from updating same area of SGA."— Presentation transcript:

1 1 Chapter 16 Latch and Mutex Contention

2 2 Architecture Overview of Latches Protect Oracle’s SGA Prevent two processes from updating same area of SGA Required to add new blocks of data to buffer cache “Lock” the buffers while they are being accessed Modified data written to latch protected redo buffer Each latch usually protects a group of blocks Can protect thousands of rows or dozens of SQL statements

3 3 Gets, Spins, and Sleeps Terminology of how Oracle obtains a latch – “Spinlock” - # of times tried before giving up – “Spins” - # of requests before sleeping – “Latch Get” – each attempt to obtain a latch – “Latch Miss” – each failed attempt to obtain a latch – “Latch Sleep” – sleeping after spinning on a latch Sessions awake either: – Automatically after a period of time – When a latch becomes available

4 4 Mutexes Similar to latches Operates in more fundamental OS calls Have lower memory & CPU overhead than latch More in quantity than latches Protects smaller number of objects Also use spinlock algorithm Unlike latches, can be held in shared mode

5 5 Latch / Mutex Contention Done via wait interface & time model Information found in V$SYSTEM_EVENT Latch sleeps recorded, latch misses are not Have their own wait event – Latch: cache buffers chains – Library cache: mutex X Also see – V$LATCH to see latch waits – ASH or AWR reports – V$SQL (CONCURRENCY_WAIT_TIME column)

6 6 Library Cache Mutex Waits New SQL statements: – Are most common reason to obtain mutex – Are also highest reason for “misses” in cache Caused by excessive hard parsing SQL – Failure to use bind variables – Shows as “library cache: mutex X” event In V$SQL – View FORCE_MATCHING_SIGNATURE column – Shows identical SQL NOT using bind variables Set CURSOR_SHARING=FORCE or SIMILAR

7 7 Library Cache Mutex Waits New SQL statements: – Are most common reason to obtain mutex – Are also highest reason for “misses” in cache Caused by excessive hard parsing SQL – Failure to use bind variables – Shows as “library cache: mutex X” event In V$SQL – View FORCE_MATCHING_SIGNATURE column – Shows identical SQL NOT using bind variables Set CURSOR_SHARING=FORCE or SIMILAR

8 8 Other Considerations Watch for Library Cache Pins Shared Pool Latch contention Periodically flush the shared pool Set shared pool to minimum value (if using automatic SGA management) Pin objects in memory Set the _SPIN_COUNT parameter

9 9 Cache Buffers Chains Latch Needed to access block from buffer cache Contention occurs with high logical read rate Reduce contention by tuning SQL – Turn unselective SQL to selective SQL – Proper index usage See V$LATCH_CHILDREN for details See X$BH (as ‘SYS’ user)

10 10 Other Latches to Watch Row cache objects latch Cache Buffers LRU chain latch Simulator LRU latch Redo allocation latch Session allocation latch Process allocation latch KKS stats latch In memory undo latch Result cache: Latch


Download ppt "1 Chapter 16 Latch and Mutex Contention. 2 Architecture Overview of Latches Protect Oracle’s SGA Prevent two processes from updating same area of SGA."

Similar presentations


Ads by Google