[20200416]關於軟軟解析的問題.txt
[20200416]關於軟軟解析的問題.txt
--//別人問的問題,如果在一個會話裡面如果一條語句存在2個子游標快取,這樣v$open_cursor看到幾條.
--//透過測試說明問題:
1.環境:
SCOTT@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
2.測試:
--//sessionn 1:
SCOTT@book> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- ------ ------- ---------- --------------------------------------------------
295 1945 39670 DEDICATED 39671 21 183 alter system kill session '295,1945' immediate;
select * from dept where deptno=10;
select * from dept where deptno=10;
select * from dept where deptno=10;
select * from dept where deptno=10;
select * from dept where deptno=10;
SCOTT@book> @ hash
HASH_VALUE SQL_ID CHILD_NUMBER HASH_HEX
---------- ------------- ------------ ---------
911274289 4xamnunv51w9j 0 3650f131
--//sql_id=4xamnunv51w9j
--//session 2:
SYS@book> column sql_text format a40
SYS@book> select * from v$open_cursor where sql_id='4xamnunv51w9j' and sid=295;
SADDR SID USER_NAME ADDRESS HASH_VALUE SQL_ID SQL_TEXT LAST_SQL_ACTIVE_TIM SQL_EXEC_ID CURSOR_TYPE
---------------- ---------- --------- ---------------- ---------- ------------- ---------------------------------------- ------------------- ----------- ---------------------
0000000085EC7D20 295 SCOTT 000000007C253FE8 911274289 4xamnunv51w9j select * from dept where deptno=10 SESSION CURSOR CACHED
--//sessionn 1:
SCOTT@book> alter session set optimizer_index_cost_adj=99;
Session altered.
select * from dept where deptno=10;
select * from dept where deptno=10;
select * from dept where deptno=10;
select * from dept where deptno=10;
select * from dept where deptno=10;
--//session 2:
SYS@book> select * from v$open_cursor where sql_id='4xamnunv51w9j' and sid=295;
SADDR SID USER_NAME ADDRESS HASH_VALUE SQL_ID SQL_TEXT LAST_SQL_ACTIVE_TIM SQL_EXEC_ID CURSOR_TYPE
---------------- ---------- --------- ---------------- ---------- ------------- ---------------------------------------- ------------------- ----------- ---------------------
0000000085EC7D20 295 SCOTT 000000007C253FE8 911274289 4xamnunv51w9j select * from dept where deptno=10 SESSION CURSOR CACHED
0000000085EC7D20 295 SCOTT 000000007C253FE8 911274289 4xamnunv51w9j select * from dept where deptno=10 SESSION CURSOR CACHED
SYS@book> select distinct * from v$open_cursor where sql_id='4xamnunv51w9j' and sid=295;
SADDR SID USER_NAME ADDRESS HASH_VALUE SQL_ID SQL_TEXT LAST_SQL_ACTIVE_TIM SQL_EXEC_ID CURSOR_TYPE
---------------- ---------- --------- ---------------- ---------- ------------- ---------------------------------------- ------------------- ----------- ---------------------
0000000085EC7D20 295 SCOTT 000000007C253FE8 911274289 4xamnunv51w9j select * from dept where deptno=10 SESSION CURSOR CACHED
--//兩行內容一樣。
SYS@book> @ tpt/sql_id 4xamnunv51w9j %
Show SQL text, child cursors and execution stats for SQLID 4xamnunv51w9j child %
HASH_VALUE CH# SQL_TEXT
---------- ---- ----------------------------------
911274289 0 select * from dept where deptno=10
911274289 1 select * from dept where deptno=10
old 24: sql_id = ('&1')
new 24: sql_id = ('4xamnunv51w9j')
old 25: and child_number like '&2'
new 25: and child_number like '%'
CH# PARENT_HANDLE OBJECT_HANDLE PLAN_HASH PARSES H_PARSES EXECUTIONS FETCHES ROWS_PROCESSED CPU_MS ELA_MS LIOS PIOS SORTS USERS_EXECUTING
---- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- -------------- ---------- ---------- ---------- ---------- ---------- ---------------
0 000000007C253FE8 000000007C252B68 2852011669 5 1 5 5 5 4.999 5.048 87 7 0 0
1 000000007C253FE8 000000007C206860 2852011669 5 1 5 5 5 1.999 2.232 10 0 0 0
--//PARENT_HANDLE對應v$open_cursor的ADDRESS。實際上v$open_cursor訪問的基表是x$kgllk。
SYS@book> @ sharepool/shp4 4xamnunv51w9j 0
old 20: WHERE kglobt03 = '&1' or kglhdpar='&1' or kglhdadr='&1' or KGLNAHSH= &2
new 20: WHERE kglobt03 = '4xamnunv51w9j' or kglhdpar='4xamnunv51w9j' or kglhdadr='4xamnunv51w9j' or KGLNAHSH= 0
TEXT KGLHDADR KGLHDPAR C40 KGLHDLMD KGLHDPMD KGLHDIVC KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 N0_6_16 N20 KGLNAHSH KGLOBT03 KGLOBT09
--------------------- ---------------- ---------------- ---------------------------------------- ---------- ---------- ---------- ---------------- ---------------- ---------- ---------- ---------- --------- ---------- ---------- ------------- ----------
child handle address 000000007C252B68 000000007C253FE8 select * from dept where deptno=10 1 0 0 000000007C252AB0 000000007C253638 4528 12144 4347 21019 21019 911274289 4xamnunv51w9j 0
child handle address 000000007C206860 000000007C253FE8 select * from dept where deptno=10 1 0 0 000000007C202300 000000007C253C00 4528 12144 4347 21019 21019 911274289 4xamnunv51w9j 1
parent handle address 000000007C253FE8 000000007C253FE8 select * from dept where deptno=10 1 0 0 000000007C253F30 00 4720 0 0 4720 4720 911274289 4xamnunv51w9j 65535
SELECT inst_id
,kgllkuse
,kgllksnm
,user_name
,kglhdpar
,kglnahsh
,kgllksqlid
,kglnaobj
,kgllkest
,DECODE (kgllkexc, 0, TO_NUMBER (NULL), kgllkexc)
,kgllkctp
,kgllkhdl
FROM x$kgllk
WHERE kglhdnsp = 0
AND kglhdpar != kgllkhdl
AND kgllksqlid = '4xamnunv51w9j'
AND kgllksnm = 295;
INST_ID KGLLKUSE KGLLKSNM USER_NAME KGLHDPAR KGLNAHSH KGLLKSQLID KGLNAOBJ KGLLKEST DECODE(KGLLKEXC,0,TO_NUMBER(NULL),KGLLKEXC) KGLLKCTP KGLLKHDL
------- ---------------- ---------- --------- ---------------- ---------- ------------- ---------------------------------- -------- ------------------------------------------- --------------------- ----------------
1 0000000085EC7D20 295 SCOTT 000000007C253FE8 911274289 4xamnunv51w9j select * from dept where deptno=10 SESSION CURSOR CACHED 000000007C252B68
1 0000000085EC7D20 295 SCOTT 000000007C253FE8 911274289 4xamnunv51w9j select * from dept where deptno=10 SESSION CURSOR CACHED 000000007C206860
--//後面的KGLLKHDL就是子游標的地址。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2686484/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20191129]關於hugepages的問題.txt
- [20181229]關於字串的分配問題.txt字串
- [20191202]關於hugepages相關問題.txt
- [20241121]測試軟軟解析遇到的疑惑.txt
- 關於軟體測試的7個核心問題
- [20181123]關於降序索引問題.txt索引
- [20180403]關於時區問題.txt
- [20200711]關於左右連線的問題.txt
- 關於軟體測試七個核心問題
- [20200416]可怕的防水牆產品.txt
- [20190918]關於函式索引問題.txt函式索引
- [20230317]關於TIME_WAIT問題.txtAI
- [20210520]關於主鍵索引問題.txt索引
- [20211018]運維中關於history的問題.txt運維
- [20210410]關於time命令的解析.txt
- [20210126]bash ln建立軟連結問題.txt
- [20181124]關於降序索引問題4.txt索引
- [20181124]關於降序索引問題3.txt索引
- [20181124]關於降序索引問題2.txt索引
- [20190910]關於降序索引問題5.txt索引
- [20211220]關於標量子查詢問題.txt
- [20190102]關於字串的分配問題(10g).txt字串
- [20180419]關於閃回的一些問題.txt
- [20180423]關於rman備份的問題2.txt
- 關於開啟軟體提示各種缺少dll問題
- 中介軟體相關問題整理
- [20191220]關於共享記憶體段相關問題.txt記憶體
- [20221212]關於pre_page_sga引數的問題.txt
- [20190603]關於dbms_output輸出問題.txt
- 軟體開發丨關於軟體重構的靈魂四問
- ORACLE的軟 軟 軟 解析!Oracle
- [20220909]bbed關於刪除記錄恢復的問題.txt
- [20180819]關於父子游標問題(11g).txt
- [20190930]關於資料結構設計問題.txt資料結構
- [20191202]關於oracle例項是否使用hugepages問題.txtOracle
- 關於quartus ii軟體中註釋亂碼問題的解決方法
- [20191223]關於共享記憶體段相關問題3.txt記憶體
- [20190320]關於使用smem檢視記憶體使用的問題.txt記憶體