oradebug poke模擬shared pool latch與硬解析原理小析
測試方法
1,如何模擬library cache load lock
2,查詢上述latch的addr,
3,用oradebug poke上面的latch addr
4,另啟一會話即發生關於上述latch wait
參考資料:
---oredebug usage
http://blog.csdn.net/tianlesoftware/article/details/6525628
測試過程
/***********獲取shared pool latch的記憶體地址*******parent latch and child latch****/
SQL> select * from v$latch where name like '%shared pool%' and addr='000000000823AC50';
ADDR LATCH# LEVEL# NAME HASH GETS MISSES SLEEPS IMMEDIATE_GETS IMMEDIATE_MISSES WAITERS_WOKEN WAITS_HOLDING_LATCH SPIN_GETS SLEEP1 SLEEP2 SLEEP3 SLEEP4 SLEEP5 SLEEP6 SLEEP7 SLEEP8 SLEEP9 SLEEP10 SLEEP11 WAIT_TIME
---------------- ---------- ---------- ---------------------------------------------------------------- ---------- ---------- ---------- ---------- -------------- ---------------- ------------- ------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
000000000823AC50 293 7 shared pool 2276811941 314022 510 39 0 0 0 0 476 0 0 0 0 0 0 0 0 0 0 0 1930812098
/******拼接oradebug poke修改記憶體命令*********/
SQL> select 'oradebug poke 0x'||addr ||' 4 0x00000001;' from v$latch_children where name='shared pool';
'ORADEBUGPOKE0X'||ADDR||'40X00
----------------------------------------------
oradebug poke 0x000000000D59A540 4 0x00000001;
oradebug poke 0x000000000D59A4A0 4 0x00000001;
oradebug poke 0x000000000D59A400 4 0x00000001;
oradebug poke 0x000000000D59A360 4 0x00000001;
oradebug poke 0x000000000D59A2C0 4 0x00000001;
oradebug poke 0x000000000D59A220 4 0x00000001;
oradebug poke 0x000000000D59A180 4 0x00000001;
7 rows selected
/**********啟用oradebug**********/
SQL> oradebug setmypid
Statement processed.
SQL> oradebug poke 0x 000000000D59A180 4 0x00000001
ORA-00073: command POKE takes between 3 and 3 argument(s)
SQL> oradebug poke 0x000000000D59A540 4 0x00000001
BEFORE: [00D59A540, 00D59A544) = 00000000
AFTER: [00D59A540, 00D59A544) = 00000001
SQL> oradebug poke 0x000000000D59A540 4 0x00000001;
BEFORE: [00D59A540, 00D59A544) = 00000001
AFTER: [00D59A540, 00D59A544) = 00000001
SQL> oradebug poke 0x000000000D59A4A0 4 0x00000001;
BEFORE: [00D59A4A0, 00D59A4A4) = 00000000
AFTER: [00D59A4A0, 00D59A4A4) = 00000001
SQL> oradebug poke 0x000000000D59A400 4 0x00000001;
BEFORE: [00D59A400, 00D59A404) = 00000000
AFTER: [00D59A400, 00D59A404) = 00000001
SQL> oradebug poke 0x000000000D59A360 4 0x00000001;
BEFORE: [00D59A360, 00D59A364) = 00000000
AFTER: [00D59A360, 00D59A364) = 00000001
SQL> oradebug poke 0x000000000D59A2C0 4 0x00000001;
BEFORE: [00D59A2C0, 00D59A2C4) = 00000000
AFTER: [00D59A2C0, 00D59A2C4) = 00000001
SQL> oradebug poke 0x000000000D59A220 4 0x00000001;
BEFORE: [00D59A220, 00D59A224) = 00000000
AFTER: [00D59A220, 00D59A224) = 00000001
SQL> oradebug poke 0x000000000D59A180 4 0x00000001;
BEFORE: [00D59A180, 00D59A184) = 00000000
AFTER: [00D59A180, 00D59A184) = 00000001
SQL> select event from v$session where type='USER';
/********另啟一個會話hang住**********/
SQL> select count(a) from t_new;
/******解除鎖定****************/
SQL> oradebug setmypid
Statement processed.
SQL> oradebug poke 0x000000000D59A540 4 0x00000000;
BEFORE: [00D59A540, 00D59A544) = 00000001
AFTER: [00D59A540, 00D59A544) = 00000000
SQL> oradebug poke 0x000000000D59A4A0 4 0x00000000;
BEFORE: [00D59A4A0, 00D59A4A4) = 00000001
AFTER: [00D59A4A0, 00D59A4A4) = 00000000
SQL> oradebug poke 0x000000000D59A400 4 0x00000000;
BEFORE: [00D59A400, 00D59A404) = 00000001
AFTER: [00D59A400, 00D59A404) = 00000000
SQL> oradebug poke 0x000000000D59A360 4 0x00000000;
BEFORE: [00D59A360, 00D59A364) = 00000001
AFTER: [00D59A360, 00D59A364) = 00000000
SQL> oradebug poke 0x000000000D59A2C0 4 0x00000000;
BEFORE: [00D59A2C0, 00D59A2C4) = 00000001
AFTER: [00D59A2C0, 00D59A2C4) = 00000000
SQL> oradebug poke 0x000000000D59A220 4 0x00000000;
BEFORE: [00D59A220, 00D59A224) = 00000001
AFTER: [00D59A220, 00D59A224) = 00000000
SQL> oradebug poke 0x000000000D59A180 4 0x00000000;
BEFORE: [00D59A180, 00D59A184) = 00000001
AFTER: [00D59A180, 00D59A184) = 00000000
SQL> oradebug poke 0x000000000D59A220 4 0x00000000;
/********另啟一個會話hang住順利繼續執行**********/
SQL> select count(a) from t_new;
COUNT(A)
----------
1
/**********上述測試說明shared pool latch會導致sql不能執行*****是不是所有的sql不能執行了,還是首次執行的sql不能執行,重複執行的sql可以執行嗎*********/
----會話1
SQL> select count(a) from t_new;
COUNT(A)
----------
1
---會話2,oredebug
SQL> oradebug poke 0x000000000D59A540 4 0x00000001;
BEFORE: [00D59A540, 00D59A544) = 00000000
AFTER: [00D59A540, 00D59A544) = 00000001
SQL> oradebug poke 0x000000000D59A4A0 4 0x00000001;
---中間略
BEFORE: [00D59A220, 00D59A224) = 00000000
AFTER: [00D59A220, 00D59A224) = 00000001
SQL> oradebug poke 0x000000000D59A180 4 0x00000001;
BEFORE: [00D59A180, 00D59A184) = 00000000
AFTER: [00D59A180, 00D59A184) = 00000001
---會話1,發現重複執行的sql不會影響
SQL> /
COUNT(A)
----------
1
---新的首次執行的sql就hang住了
SQL> select count(1) from t_new;
小結:1,shared pool latch用於硬解析,即首次執行sql會持此鎖,如果軟解析,不會持此鎖
2,所以如果生產系統出現過高的shared pool latch,表示sql寫得很爛,從減少硬解析
入手吧
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-759240/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 等待模擬-library cache shared pool 硬解析
- 優化Shared Pool Latch與Library Cache Latch競爭優化
- 在oracle 10.2.0.5分析硬解析及軟解析及軟軟解析獲取shared pool latch機制系列五Oracle
- latch:shared pool的一點理解
- Shared pool的library cache lock/pin及硬解析
- 轉_診斷latch:shared pool等待事件事件
- SHARED_POOL解析
- 《深入解析Oracle》第六章,Buffer Cache與Shared Pool原理Oracle
- 基於oradebug poke分析不同redo相關latch獲取的先後次序
- 共享池之六:shared pool latch/ library cache latch /lock pin 簡介
- Oracle記憶體分配與使用小記(二)Shared Pool and Large PoolOracle記憶體
- 由oradebug poke process allocation latch引發dfs lock handle等待事件進一步分析事件
- Shared Pool 的基本原理
- shared pool library cache latch 競爭優化辦法優化
- Shared Pool優化和Library Cache Latch衝突優化優化
- NVMe SSD的GC演算法與模擬原理解析GC演算法
- Shared Pool 的轉儲與分析
- 基於引數shared_pool_reserved_size進一步理解共享池shared pool原理
- 【Shared Pool】使用DBMS_SHARED_POOL包將PL/SQL大物件儲存到Shared PoolSQL物件
- 故障排除:Shared Pool優化和Library Cache Latch衝突優化優化
- Oracle shared poolOracle
- _shared_pool_reserved_pct or shared_pool_reserved_size with ASMMASM
- 模擬產生CBC LATCH與buffer busy wait等待事件AI事件
- zt_Oracle shared pool internals_共享池_shared_poolOracle
- Keil的軟體模擬和硬體模擬
- SQL在shared pool中的解析過程問題SQL
- SHARED POOL總結
- 理解Oracle Shared PoolOracle
- 深入小程式系列之一:小程式核心原理及模擬
- 模擬退火原理
- [20210520]11g shared pool latch與library cache mutex的簡單探究.txtMutex
- [20210521]11g shared pool latch與library cache mutex的簡單探究4.txtMutex
- [20170923]模擬session allocation latchSession
- Oracle Shared Pool Memory ManagementOracle
- ORACLE SGA之shared poolOracle
- new&instanceof原理解析及模擬實現
- 使用DBMS_SHARED_POOL包將PL/SQL大物件儲存到Shared PoolSQL物件
- 由oradebug poke推進scn理解scn base及scn wrap系列一