latch:shared pool的一點理解
latch:shared pool
shared pool latch 起到保護堆的作用,為了查詢free chunk,檢索空閒列,分配適當的chunk,
必要時候分割chunk。這些全部只能在獲得shared pool latch之後才能執行。
因此在獲得shared pool latch過程中會發生latch:shared pool等待事件.
一般情況下一個例項上只有一個latch:shared pool
harding parse嚴重時,會發生分割chunk的現象.
---==============================================================
測試latch:shard pool等待事件
建立測試指令碼:
create or replace procedure tt_pro is
begin
for i in 1..100000 loop
execute immediate 'select * from tt where object_id='||i;
end loop;
end;
/
同時在三個會話執行這個指令碼,檢視v$session_event
select * from (
select event,total_waits,time_waited from v$session_event where sid in(12,192,197) order by 2 desc )where rownum<=10
EVENT TOTAL_WAITS TIME_WAITED
------------------------------ ----------- -----------
latch: shared pool 84996 612
latch: shared pool 57746 500
latch: shared pool 56557 640
cursor: pin S wait on X 9798 9471
cursor: pin S wait on X 8682 8370
library cache: mutex X 471 9
library cache: mutex X 408 12
library cache: mutex X 241 10
library cache lock 231 81
events in waitclass Other 224 675
10 rows selected.
如果發生latch:shared pool等待事件,不應該加大共享池,加大了共享池,
相應的要管理的chunk數量也要增加,檢索空閒列的時候,佔有
shared pool latch的時間會增大。
---==============================================================
相應的解決方法:
1)oracle9i之後,可以有多個共享池(副池),最多有7個副池分別管理。
oracle在cpu數位4,共享池大小為250M以上的情況下,透過建立與
_kghdsidx_count值相同量的副池來管理共享池。副池也是獨立的共享池結構。
2)減少共享的大小,這樣就可以減少佔有shared pool latch的時間。
但這回導致ora-04031錯誤
可以利用dbms_shared_pool.keep指定物件永久置於共享池中,來消除問題
3)cursor sharing
---===============================================================
下面,測試一下,使用過個共享池的情況下,會不會減少latch:shared pool
確認cpu_count大於4,共享池大小大於250M
SQL> show parameter cpu_count
NAME TYPE VALUE
------------------------------------ ---------------------- ------------------------------
cpu_count integer 4
SQL> show sga
Total System Global Area 626327552 bytes
Fixed Size 2178336 bytes
Variable Size 461374176 bytes
Database Buffers 155189248 bytes
Redo Buffers 7585792 bytes
SQL> alter system set "_kghdsidx_count"=4 scope=spfile;
System altered.
SQL> select name,gets from v$latch_children where name='shared pool';
NAME GETS
-------------------- ----------
shared pool 19
shared pool 19
shared pool 19
shared pool 27058
shared pool 27862
shared pool 31982
shared pool 27345
可以看出,4個shared pool latch 被啟用
然後再在三個會話中重新執行tt_pro指令碼,看看情況
SQL> select * from (
2 select event,total_waits,time_waited from v$session_event where sid in(9,10,199) order by 2 desc )where rownum<=10
3 ;
EVENT TOTAL_WAITS TIME_WAITED
------------------------------ ----------- -----------
latch: shared pool 23120 126
cursor: pin S wait on X 18792 18766
latch: shared pool 14996 68
cursor: pin S wait on X 13740 13490
latch: shared pool 9860 70
library cache lock 716 256
library cache lock 705 262
library cache: mutex X 692 35
library cache: mutex X 605 41
library cache load lock 479 2
10 rows selected.
相應的latch:shared pool減少很多.
---====================================================
hard parse引起的library cache爭用比shared pool爭用多
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8494287/viewspace-1444311/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 轉_診斷latch:shared pool等待事件事件
- 理解Oracle Shared PoolOracle
- 優化Shared Pool Latch與Library Cache Latch競爭優化
- 關於latch的一點點理解
- 共享池之六:shared pool latch/ library cache latch /lock pin 簡介
- 基於引數shared_pool_reserved_size進一步理解共享池shared pool原理
- shared pool library cache latch 競爭優化辦法優化
- Shared Pool優化和Library Cache Latch衝突優化優化
- 簡單分析shared pool(一)
- 深入理解shared pool共享池之library cache系列一
- 【Shared Pool】使用DBMS_SHARED_POOL包將PL/SQL大物件儲存到Shared PoolSQL物件
- 故障排除:Shared Pool優化和Library Cache Latch衝突優化優化
- oradebug poke模擬shared pool latch與硬解析原理小析
- Oracle shared poolOracle
- _shared_pool_reserved_pct or shared_pool_reserved_size with ASMMASM
- zt_Oracle shared pool internals_共享池_shared_poolOracle
- SHARED POOL總結
- SHARED_POOL解析
- 【每日一摩斯】-Shared Pool優化和Library Cache Latch衝突優化 (1523934.1)-系列6優化
- 【每日一摩斯】-Shared Pool優化和Library Cache Latch衝突優化 (1523934.1)-系列5優化
- 【每日一摩斯】-Shared Pool優化和Library Cache Latch衝突優化 (1523934.1)-系列4優化
- 【每日一摩斯】-Shared Pool優化和Library Cache Latch衝突優化 (1523934.1)-系列3優化
- 【每日一摩斯】-Shared Pool優化和Library Cache Latch衝突優化 (1523934.1)-系列2優化
- 【每日一摩斯】-Shared Pool優化和Library Cache Latch衝突優化 (1523934.1)-系列1優化
- 分析為何oracle 10.2.0.5只會獲取child#=1的shared pool latch之系列六Oracle
- Shared Pool 的基本原理
- Shared Pool 的轉儲與分析
- Oracle Shared Pool Memory ManagementOracle
- ORACLE SGA之shared poolOracle
- 深入理解shared pool共享池之library cache系列二
- 使用DBMS_SHARED_POOL包將PL/SQL大物件儲存到Shared PoolSQL物件
- dbms_shared_pool keep物件到share pool中物件
- Shared pool深入分析及效能調整(一)
- shared_pool的sql命中率SQL
- SHARED POOL 基礎知識
- 簡單分析shared pool(二)
- 簡單分析shared pool(三)
- shared_pool_spare_free.sqlSQL