Presentation is loading. Please wait.

Presentation is loading. Please wait.

Shared Pool Waits Kyle Hailey

Similar presentations


Presentation on theme: "Shared Pool Waits Kyle Hailey"— Presentation transcript:

1 Shared Pool Waits Kyle Hailey http://perfvision.com/ftp/emea2010

2 Library Cache locks and pins Row Cache Lock
Shared Pool Waits Latches Latch: Library Cache Latch: Shared Pool Latch Mutexes Library Cache locks and pins Row Cache Lock Copyright 2006 Kyle Hailey

3 Library Cache Lib Cache Copyright 2006 Kyle Hailey

4 Shared Pool Structure Hash Table SQL statements are hashed
On their text. The resulting Hash is used to find the appropriate bucket, which is searched for the Compiled SQL. If it’s not there, then we parse it. handle handle handle handle handle handle handle handle handle handle handle handle handle Copyright 2006 Kyle Hailey

5 Shared Pool Latch Cause: Hard Parses by Concurrent Sessions
Contention can arise when too many sessions are hard parsing and looking for space in the shared pool. Protects Space Allocation in the Shared Pool Protects the structure containing memory chunks Ensures two users don’t get same chunk of memory Copyright 2006 Kyle Hailey

6 Shared Pool Latch Shared Pool Free Space
Shared Pool Latch covers changes in the lists of free memory chunks Shared Pool Free Space Copyright 2006 Kyle Hailey

7 Shared Pool Latch 8.1.6 Shared Pool pre 8.1.6 Bucket sizes
0 < 80 bytes 1 < 144 2 < 272 3 < 528 4 < 1040 5 < 2064 6 < 4112 7 < 8208 8 < 16400 9 < 32784 10 bigger Shared Pool pre 8.1.6 Memory Chunk Buckets Copyright 2006 Kyle Hailey

8 Shared Pool Latch Shared Pool Latch Shared Pool Free Space 8.1.6+
Before 8.1.6, oversizing the shared pool could be a problem, after should be fine Copyright 2006 Kyle Hailey

9 Shared Pool Latch Shared Pool Memory Chunk Buckets 8.1.6 and up
bytes bytes … (0-198 only have one chunk size in bucket) 808 bytes 812 to 872 …. ( only have 16 possible chunk sizes per bucket) 254 bigger Copyright 2006 Kyle Hailey

10 Library Cache Latches Protects changes in Library Cache
Library Locks are not atomic Thus need library cache latch Broken out into library cache pin allocation library cache lock allocation library cache lock library cache library cache pin library cache load lock Copyright 2006 Kyle Hailey

11 Library Cache Find and Lock Pin (and Load) Hash Table pin lock pin
handle handle Find and Lock Pin (and Load) Copyright 2006 Kyle Hailey

12 Library Cache Structures
Hash Table waiters pin lock Library Cache Latches pin lock pin lock holders pin lock Handle Cursor(0) flags handle handle handle Cursor (0) Heap 1 pin lock Heap 0 Heap 6 pin lock Child cursor 1 Child cursor 2 Child cursor 3 Copyright 2006 Kyle Hailey

13 Library Cache Latch Contention
Library Cache Latch Contention because of these possibilities: Excessive Hard Parsing Not Sharing SQL – use of Literal Values Shared Pool too small Too many invalidations Excessive Soft Parsing Copyright 2006 Kyle Hailey

14 Sharing SQL & Literals select plan_hash_value, count(plan_hash_value)
from v$sql group by plan_hash_value order by count(plan_hash_value) select * from ( select PLAN_HASH_VALUE, count(PLAN_HASH_VALUE) cnt from v$sql group by PLAN_HASH_VALUE order by count(PLAN_HASH_VALUE) ) where cnt > 5 and plan_hash_value > 0 / PLAN_HASH_VALUE CNT Copyright 2006 Kyle Hailey

15 Sharing SQL & Literals select sql_text from v$sql where
PLAN_HASH_VALUE CNT select sql_text from v$sql where plan_hash_value = and rownum < 10; SQL_TEXT SELECT * FROM dual WHERE dummy= SELECT * FROM dual WHERE dummy= SELECT * FROM dual WHERE dummy= SELECT * FROM dual WHERE dummy= SELECT * FROM dual WHERE dummy= SELECT * FROM dual WHERE dummy= SELECT * FROM dual WHERE dummy= SELECT * FROM dual WHERE dummy= SELECT * FROM dual WHERE dummy= select * from ( select PLAN_HASH_VALUE, count(PLAN_HASH_VALUE) cnt from v$sql group by PLAN_HASH_VALUE order by count(PLAN_HASH_VALUE) ) where cnt > 5 and plan_hash_value > 0 / Copyright 2006 Kyle Hailey

16 Cursor Sharing Bind Variables Cursor_Sharing
Select * from dual where dummy = :var; Select sum(money) from orders where odate > :odate; Cursor_Sharing Cursor_sharing = Force Oracle replaces variables with bind variables Defaults to Exact Copyright 2006 Kyle Hailey

17 Shared Pool too Small SQL> select namespace, reloads from v$librarycache; NAMESPACE RELOADS SQL AREA TABLE/PROCEDURE Reloads means Cursor heaps were kicked out implying shared_pool too small Copyright 2006 Kyle Hailey

18 Invalidations Changes in dependent objects invalidate cursor
SQL> select namespace, invalidations from v$librarycache; NAMESPACE INVALIDATIONS SQL AREA Changes in dependent objects invalidate cursor FOR i IN LOOP l_cursor:=dbms_sql.open_cursor; dbms_sql.parse(l_cursor, 'SELECT * FROM toto',dbms_sql.native); execute immediate 'analyze table toto compute statistics'; dbms_sql.close_cursor(l_cursor); END LOOP; FOR i IN LOOP l_cursor:=dbms_sql.open_cursor; dbms_sql.parse(l_cursor, 'SELECT * FROM toto',dbms_sql.native); execute immediate 'analyze table toto compute statistics'; dbms_sql.close_cursor(l_cursor); END LOOP; CREATE OR REPLACE Procedure parse_same IS l_cursor integer default 0; rc integer default 0; stmt varchar2(1000); BEGIN FOR i IN LOOP l_cursor:=dbms_sql.open_cursor; dbms_sql.parse(l_cursor,'SELECT * FROM toto',dbms_sql.native); execute immediate 'analyze table toto compute statistics'; dbms_sql.close_cursor(l_cursor); END LOOP; END; / show errors execute parse_same; Copyright 2006 Kyle Hailey

19 Soft Parsing Cursor Memory = Latch Re-Executing a Cursor
lock lock lock lock lock pin pin pin pin pin Execute 1 Execute 2 Execute 3 Execute 4 Execute 5 Re-Executing a Cursor Libray Cache latch Locks Pins Copyright 2006 Kyle Hailey

20 Session Cached Cursors
= Latch Cursor Memory lock pin pin pin pin pin Execute 1 Execute 2 Execute 3 Execute 4 Execute 5 Session_cached_cursor: If Opening/Closing keeps locked in Memory Copyright 2006 Kyle Hailey

21 Session Cached Cursors
FOR i IN LOOP l_cursor:=dbms_sql.open_cursor; dbms_sql.parse(l_cursor,'SELECT * FROM dual’,dbms_sql.native); dbms_sql.close_cursor(l_cursor); END LOOP; Session_cached_cursors=0 Latch Gets library cache lock ,028 library cache ,074 library cache pin ,048 Session_cached_cursors=20 library cache lock library cache ,061 CREATE OR REPLACE Procedure parse_same IS l_cursor integer default 0; BEGIN FOR i IN LOOP l_cursor:=dbms_sql.open_cursor; dbms_sql.parse(l_cursor,'SELECT * FROM dual',dbms_sql.native); dbms_sql.close_cursor(l_cursor); END LOOP; END; / show errors set serveroutput on execute dbms_output.enable( ); execute slatch.b; execute parse_same; execute slatch.e; Copyright 2006 Kyle Hailey

22 Cursor Space for Time Cursor Memory = Latch Close Cursor Open Cursor
lock Close Cursor Open Cursor pin Execute 1 Execute 2 Execute 3 Execute 4 Execute 5 Cursor_space_for_time=true : if open and re-executing – keeps cursor pinned (Cursor already locked because cursor is kept open) Copyright 2006 Kyle Hailey

23 Cursor Space For Time Cursor_space_for_time=false Latch Gets
FOR i IN LOOP rc:=dbms_sql.execute(l_cursor); IF DBMS_SQL.FETCH_ROWS (l_cursor) < 0 THEN DBMS_SQL.COLUMN_VALUE (l_cursor, 1, cnt); end if; End loop; Cursor_space_for_time=false Latch Gets library cache lock library cache ,096 library cache pin ,044 Cursor_space_for_time=true library cache lock library cache library cache pin REATE OR REPLACE Procedure parse_same IS l_cursor integer default 0; rc integer default 0; BEGIN l_cursor:=dbms_sql.open_cursor; dbms_sql.parse(l_cursor,'select count(*) from dual',dbms_sql.native); FOR i IN LOOP rc:=dbms_sql.execute(l_cursor); rc:=DBMS_SQL.FETCH_ROWS (l_cursor); END LOOP; dbms_sql.close_cursor(l_cursor); END; / show errors set serveroutput on execute dbms_output.enable( ); execute slatch.b; execute parse_same; execute slatch.e; Cursor_space_for_time=false Latch Gets library cache lock library cache ,096 library cache pin ,044 Cursor_space_for_time=true library cache lock library cache library cache pin Copyright 2006 Kyle Hailey

24 Cursor Sharing select * from ( select sql_id, count(*) cnt
handle pin lock handle Cursor (0) Handle Cursor(0) flags select * from ( select sql_id, count(*) cnt from V$SQL_SHARED_CURSOR group by sql_id ) where cnt > 5 order by cnt; Child cursor 0 select sid, KGLNAOBJ from x$kglob x, v$session_wait w where KGLHDADR=P1RAW and event like '%library%'; find the waiters and who blocks them column wevent format a20 column bevent format a20 select waiter.sid waiter, waiter.p1raw wlockp1, waiter.event wevent, blocker_event.sid blocker, blocker_event.event bevent from x$kglpn p, gv$session blocker_session, gv$session_wait waiter, gv$session_wait blocker_event where p.kglpnuse=blocker_session.saddr and p.kglpnhdl=waiter.p1raw and (waiter.event like 'library cache lock' ) and blocker_event.sid=blocker_session.sid order by waiter.p1raw,waiter.sid / find how many sessions a blocker blocks column event format A20 select s.sid, blocked.p1raw, holder.event, count(s.sid) users_blocked v$session s, v$session_wait blocked, v$session_wait holder p.kglpnhdl=blocked.p1raw and s.saddr=p.kglpnuse and blocked.event like 'library cache lock' and holder.sid=s.sid group by s.sid, blocked.p1raw,holder.event ; Child cursor 1 Child cursor 2 Copyright 2006 Kyle Hailey

25 V$SQL_SHARED_CURSOR 10gR2, 53 reasons why cursors aren’t shared
If using “cursor_sharing=similar” might not work – bugs Examples OPTIMIZER_MODE_MISMATCH , see V$SQL_OPTIMIZER_ENV STATS_ROW_MISMATCH, could be sql trace AUTH_CHECK_MISMATCH TRANSLATION_MISMATCH – different object in SQL stmt BIND_MISMATCH – bind variable different sizes LANGUAGE_MISMATCH – NLS Language V$SYS_OPTIMIZER_ENV - Instance level V$SES_OPTIMIZER_ENV - Session level V$SQL_OPTIMIZER_ENV - Statement level Supported Optimizer parameters active_instance_count bitmap_merge_area_size cpu_count cursor_sharing hash_area_size optimizer_dynamic_sampling optimizer_features_enable optimizer_index_caching optimizer_index_cost_adj optimizer_mode optimizer_secure_view_merging parallel_ddl_mode parallel_dml_mod parallel_execution_enabled parallel_query_mode parallel_threads_per_cpu pga_aggregate_target query_rewrite_enabled query_rewrite_integrity skip_unusable_indexes sort_area_retained_size sort_area_size star_transformation_enabled statistics_level workarea_size_policy Unsupported parameters /* thanks to Julian Dyke */ SELECT pname_qkscesyrow FROM x$qkscesys WHERE SUBSTR (pname_qkscesyrow,1,1) = '_' ORDER BY 1; Copyright 2006 Kyle Hailey

26 V$SQL_SHARED_CURSOR UNBOUND_CURSOR USER_BIND_PEEK_MISMATCH
SQL_TYPE_MISMATCH OPTIMIZER_MISMATCH OUTLINE_MISMATCH STATS_ROW_MISMATCH LITERAL_MISMATCH SEC_DEPTH_MISMATCH EXPLAIN_PLAN_CURSOR BUFFERED_DML_MISMATCH PDML_ENV_MISMATCH INST_DRTLD_MISMATCH SLAVE_QC_MISMATCH TYPECHECK_MISMATCH AUTH_CHECK_MISMATCH BIND_MISMATCH DESCRIBE_MISMATCH LANGUAGE_MISMATCH TRANSLATION_MISMATCH ROW_LEVEL_SEC_MISMATCH INSUFF_PRIVS INSUFF_PRIVS_REM REMOTE_TRANS_MISMATCH LOGMINER_SESSION_MISMATCH INCOMP_LTRL_MISMATCH OVERLAP_TIME_MISMATCH SQL_REDIRECT_MISMATCH MV_QUERY_GEN_MISMATCH USER_BIND_PEEK_MISMATCH TYPCHK_DEP_MISMATCH NO_TRIGGER_MISMATCH FLASHBACK_CURSOR ANYDATA_TRANSFORMATION INCOMPLETE_CURSOR TOP_LEVEL_RPI_CURSOR DIFFERENT_LONG_LENGTH LOGICAL_STANDBY_APPLY DIFF_CALL_DURN BIND_UACS_DIFF PLSQL_CMP_SWITCHS_DIFF CURSOR_PARTS_MISMATCH STB_OBJECT_MISMATCH ROW_SHIP_MISMATCH PQ_SLAVE_MISMATCH TOP_LEVEL_DDL_MISMATCH MULTI_PX_MISMATCH BIND_PEEKED_PQ_MISMATCH MV_REWRITE_MISMATCH ROLL_INVALID_MISMATCH OPTIMIZER_MODE_MISMATCH PX_MISMATCH MV_STALEOBJ_MISMATCH FLASHBACK_TABLE_MISMATCH LITREP_COMP_MISMATCH Copyright 2006 Kyle Hailey

27 10g : Mutex A new semaphore method which can replace latches Mutex
Mutual exclusion object Similar to a latch, prevents Deallocation while someone is using it Read/write while someone else is modifying Different from latch Every object can have it’s own mutex A mutex can cover multiple objects Usually dynamically allocated along with structure they protect Can be stored in the structure, thus destroying structure deletes the mutex Copyright 2006 Kyle Hailey

28 Mutex Views and Stats Views V$mutex_sleep V$mutex_sleep_history
Cursor:pin S Pin cursor for execute, and cursor is currently being examined by another Session Bug Cursor:pin S wait on X Pinning a cursor for execute Bug on typically with DBMS_STATS Metalink Note: , Note: , bug Instead of “library cache pin” cursor_space_for_time not needed Instead of latching for execute pin we use a shared mutex If can’t get the mutex spin aSQL> desc v$MUTEX_SLEEP_HISTORY Name Null? Type SLEEP_TIMESTAMP TIMESTAMP(6) MUTEX_TYPE VARCHAR2(32) GETS NUMBER SLEEPS NUMBER REQUESTING_SESSION NUMBER BLOCKING_SESSION NUMBER LOCATION VARCHAR2(40) MUTEX_VALUE RAW(4) P NUMBER P1RAW RAW(4) P NUMBER P NUMBER P NUMBER P VARCHAR2(64) QL> desc V$mutex_sleep WAIT_TIME NUMBER cursor: mutex S A session waits on this event when it is requesting a mutex in shared mode, when another session is currently holding a this mutex in exclusive mode on the same cursor object. ParameterDescriptionP1Hash value of cursorP2Mutex value (top 2 bytes contain SID holding mutex in exclusive mode, and bottom two bytes usually hold the value 0)P3Mutex where (an internal code locator) OR'd with Mutex Sleeps cursor: mutex X The session requests the mutex for a cursor object in exclusive mode, and it must wait because the resource is busy. The mutex is busy because either the mutex is being held in exclusive mode by another session or the mutex is being held shared by one or more sessions. The existing mutex holder(s) must release the mutex before the mutex can be granted exclusively. cursor: pin S A session waits on this event when it wants to update a shared mutex pin and another session is currently in the process of updating a shared mutex pin for the same cursor object.  This wait event should rarely be seen because a shared mutex pin update is very fast. Wait Time: Microseconds ParameterDescriptionP1Hash value of cursorP2Mutex value (top 2 bytes contains SID holding mutex in exclusive mode, and bottom two bytes usually hold the value 0)P3Mutex where (an internal code locator) OR'd with Mutex Sleeps cursor: pin S wait on X A session waits for this event when it is requesting a shared mutex pin and another session is holding an exclusive mutex pin on the same cursor object. cursor: pin X A session waits on this event when it is requesting an exclusive mutex pin for a cursor object and it must wait because the resource is busy. The mutex pin for a cursor object can be busy either because a session is already holding it exclusive, or there are one or more sessions which are holding shared mutex pin(s). The exclusive waiter must wait until all holders of the pin for that cursor object have released it, before it can be granted. An example of the ‘cursor: pin S wait on X’ event. • If a session is waiting on the wait event ‘cursor: pin S wait on X’, the session is most likely trying to execute a cursor (pin S), and must wait as another session (who is most likely parsing the cursor) has it pinned X (wait on X) • v$session.p1 can be used to compare with v$mutex_sleep_history.mutex_identifier • Example v$session data (64 bit platform), from an instance where the mutex holder was hung due to a bug not related to mutexes, causing requestors to back up behind the holder: select p1, p2raw, count(*) from v$session where event = ‘cursor: pin S wait on X’ and wait_time = 0 group by p1, p2; P1 P2RAW COUNT(*) <Mutex Id> < SId><RefCnt> As you can see, 9 sessions were waiting for Session Id 0x1397, which was holding exclusive the Mutex with the Id The Ref Count is zero, as we would expect. The 9 sessions are waiting to execute the cursor protected by mutex Id If latches had been in use instead of mutexes, it is likely this bug would have had a greater impact, as there would have been many more requestors backed up on a latch which protects many objects, than a mutex that in this case protects just one cursor. • To find the blocking session, use the top bytes of v$session.p2raw e.g. the top bytes of p2raw is the blocker 0x which when converted to decimal, is session Id 5015. Note that v$session.blocking_session is not populated for mutex related waits in 10.2 Fixed ? Turn off with _kks_use_mutex_pin=FALSE" Copyright 2006 Kyle Hailey

29 Debugging Pin Waits select p1, p2raw, count(*) from v$session
NAME P1 P P3 cursor: mutex X idn value where|sleeps cursor: mutex S idn value where|sleeps cursor: pin S wait on X idn value where|sleeps cursor: pin X idn value where|sleeps cursor: pin S idn value where|sleeps select p1, p2raw, count(*)   from v$session  where event = ‘cursor: pin S wait on X’    and wait_time = 0 Group by p1, p2; Images from Marcin Przepiorowski      P1  P2RAW            COUNT(*)            9 <Mutex Id>  <   SId><RefCnt> select to_number(1397,'XXXX') from dual; TO_NUMBER(1397,'XXXX') 5015 Select serial# from v$session where sid=5015; SERIAL# 82 Alter system kill session ‘5015,82’; Copyright 2006 Kyle Hailey

30 lock and pins Library Cache Pin Library Cache Lock
Library Cache Load Lock Contention when Sessions try to load/compile same SQL Compile package others are running Locks and Pins are usually in share mode unless modifications are being made Copyright 2006 Kyle Hailey

31 Lib Cache Lock : blockers and waiters
select waiter.sid waiter, waiter.event wevent, to_char(blocker_event.sid)||','||to_char(blocker_session.serial#) blocker, substr(decode(blocker_event.wait_time, 0, blocker_event.event, 'ON CPU'),1,30) bevent from x$kglpn p, gv$session blocker_session, gv$session_wait waiter, gv$session_wait blocker_event where p.kglpnuse=blocker_session.saddr and p.kglpnhdl=waiter.p1raw and waiter.event in ( 'library cache pin' , 'library cache lock' , 'library cache load lock') and blocker_event.sid=blocker_session.sid and waiter.sid != blocker_event.sid order by waiter.p1raw,waiter.sid; WAITER WLOCKP WEVENT BLOCKER BEVENT B76AB620 library cache pin 135,15534 PL/SQL lock timer -- Output -- WAITER WLOCKP WEVENT BLOCKER BEVENT B76AB620 library cache pin 135,15534 PL/SQL lock timer column wevent format a20 column bevent format a20 column blocker format a10 column waiter format 99999 select waiter.sid waiter, waiter.event wevent, to_char(blocker_event.sid)||','||to_char(blocker_session.serial#) blocker, substr(decode(blocker_event.wait_time, 0, blocker_event.event, 'ON CPU'),1,30) bevent, --blocker_event.event bevent, blocker_session.SQL_HASH_VALUE sql_hash, sql.sql_text from x$kglpn p, gv$session blocker_session, gv$session_wait waiter, gv$session_wait blocker_event, gv$sqltext sql where blocker_session.SQL_HASH_VALUE =sql.HASH_VALUE (+) and (sql.PIECE=0 or sql.piece is null) and p.kglpnuse=blocker_session.saddr and p.kglpnhdl=waiter.p1raw and (waiter.event = 'library cache pin' or waiter.event = 'library cache lock' or waiter.event = 'library cache load lock') and blocker_event.sid=blocker_session.sid and waiter.sid != blocker_event.sid order by waiter.p1raw,waiter.sid / Copyright 2006 Kyle Hailey

32 Solutions Library Cache Pin Library Cache Lock Library Cache Load Lock
Have only one Session compile the same cursor at a time Avoid compiling while executing Waits – find “competing” Sessions Copyright 2006 Kyle Hailey

33 row cache lock : args P1 = cache# P2 = Lock Mode Held
P3 = Lock Mode Requested select parameter as “name” from v$rowcache where cache# = P1; Copyright 2006 Kyle Hailey

34 Row Cache Lock - ASH select ash.session_id sid,
ash.blocking_session bsid, nvl(o.object_name,to_char(CURRENT_OBJ#)) obj, o.object_type otype, CURRENT_FILE# filen, CURRENT_BLOCK# blockn, ash.SQL_ID, nvl(rc.name,to_char(ash.p3)) row_cache from v$active_session_history ash, ( select cache#, parameter name from v$rowcache ) rc, all_objects o where event='row cache lock' and rc.cache#(+)=ash.p1 and o.object_id (+)= ash.CURRENT_OBJ# and ash.session_state='WAITING' and ash.sample_time > sysdate - &minutes/(60*24) Order by sample_time set linesize 120 col block_type for a20 col objn for a25 col obj for a20 col otype for a15 col filen for 9999 col blockn for col sid for 9999 col bsid for 9999 select ash.session_id sid, ash.blocking_session bsid, --ash.p1, --ash.p2, --ash.p3, nvl(o.object_name,to_char(CURRENT_OBJ#)) obj, o.object_type otype, CURRENT_FILE# filen, CURRENT_BLOCK# blockn, ash.SQL_ID, nvl(rc.name,to_char(ash.p3)) row_cache from v$active_session_history ash, ( select cache#, parameter name from v$rowcache ) rc, all_objects o where event='row cache lock' and rc.cache#(+)=ash.p1 and o.object_id (+)= ash.CURRENT_OBJ# and ash.session_state='WAITING' and ash.sample_time > sysdate - &minutes/(60*24) --and w.class# > 18 Order by sample_time /

35 Row Cache Lock - ASH SID BSID OBJ OTYPE FILEN BLOCKN SQL_ID ROW_CACHE
select ash.session_id sid, ash.blocking_session bsid, nvl(o.object_name,to_char(CURRENT_OBJ#)) obj, o.object_type otype, CURRENT_FILE# filen, CURRENT_BLOCK# blockn, ash.SQL_ID, nvl(rc.name,to_char(ash.p3)) row_cache from v$active_session_history ash, ( select cache#, parameter name from v$rowcache ) rc, all_objects o where event='row cache lock' and rc.cache#(+)=ash.p1 and o.object_id (+)= ash.CURRENT_OBJ# and ash.session_state='WAITING' and ash.sample_time > sysdate - &minutes/(60*24) Order by sample_time SID BSID OBJ OTYPE FILEN BLOCKN SQL_ID ROW_CACHE y8w0sfqb61m dc_sequences dc_sequences dc_sequences dc_sequences dc_sequences set linesize 120 col block_type for a20 col objn for a25 col obj for a20 col otype for a15 col filen for 9999 col blockn for col sid for 9999 col bsid for 9999 select ash.session_id sid, ash.blocking_session bsid, --ash.p1, --ash.p2, --ash.p3, nvl(o.object_name,to_char(CURRENT_OBJ#)) obj, o.object_type otype, CURRENT_FILE# filen, CURRENT_BLOCK# blockn, ash.SQL_ID, nvl(rc.name,to_char(ash.p3)) row_cache from v$active_session_history ash, ( select cache#, parameter name from v$rowcache ) rc, all_objects o where event='row cache lock' and rc.cache#(+)=ash.p1 and o.object_id (+)= ash.CURRENT_OBJ# and ash.session_state='WAITING' and ash.sample_time > sysdate - &minutes/(60*24) --and w.class# > 18 Order by sample_time /

36 Row Cache Lock Select seq.next_val Sequence cache set to 1
Default sequence cache is 20 Enter value for 1: 41y8w0sfqb61m SQL_FULLTEXT SELECT TOTO_SEQ.NEXTVAL FROM DUAL Copyright 2006 Kyle Hailey

37 Library Cache Latch Solutions
Share Cursors Use bind variables User cursor_sharing=force Avoid invalidations and reloads Size shared_pool large enough Avoid changing dependent objects Soft Parsing Session_cached_cursors =20 : keep across open/close Cursor_space_for_time=true : keep pinned across executes hold_cursor=true : used in precompilers Copyright 2006 Kyle Hailey

38 Summary Shared Pool Latch Loading Same Cursor Row Cache Lock
Shared pool too small or too much hard parsing Loading Same Cursor Library Cache Pin Library Cache Lock Library Cache Load Lock Row Cache Lock Depends on the cache Copyright 2006 Kyle Hailey


Download ppt "Shared Pool Waits Kyle Hailey"

Similar presentations


Ads by Google