[20180906]測試同一會話多個子遊標是否快取.txt
[20180906]測試同一會話多個子遊標是否快取.txt
1.環境:
SCOTT@test01p> @ ver1
PORT_STRING VERSION BANNER CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0 12.1.0.1.0 Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
SCOTT@test01p> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- -------------------- ------- ---------- --------------------------------------------------
234 27 2444:3304 DEDICATED 5148 55 9 alter system kill session '234,27' immediate;
SCOTT@test01p> show parameter optimizer_index_caching
NAME TYPE VALUE
------------------------------------ -------------------- ----------
optimizer_index_caching integer 0
2.測試:
--//session 1:
select * from deptx where deptno=10;
select * from deptx where deptno=10;
select * from deptx where deptno=10;
select * from deptx where deptno=10;
--//確定sql_id=07447rnnn54q7.
--//session 2:
SYS@test> select * from V$OPEN_CURSOR where sid=234 and sql_id='07447rnnn54q7';
SADDR SID USER_NAME ADDRESS HASH_VALUE SQL_ID SQL_TEXT LAST_SQL_ACTIVE_TIM SQL_EXEC_ID CURSOR_TYPE CHILD_ADDRESS CON_ID
---------------- --- --------- ---------------- ---------- ------------- ------------------------------------ ------------------- ----------- --------------------- ---------------- ------
000007FF312D41D8 234 SCOTT 000007FF25F196C8 692228807 07447rnnn54q7 select * from deptx where deptno=10 SESSION CURSOR CACHED 000007FF25F18218 3
--//該語句已經進入游標快取..
SYS@test> @ sharepool/shp4 07447rnnn54q7 0
TEXT KGLHDADR KGLHDPAR C40 KGLHDLMD KGLHDPMD KGLHDIVC KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 N0_6_16 N20 KGLNAHSH KGLOBT03 KGLOBT09
-------------- ---------------- ---------------- ---------------------------------------- ---------- ---------- ---------- ---------------- ---------------- ---------- ---------- ---------- --------- ---------- ---------- ------------- ----------
子游標控制程式碼地址 000007FF25F18218 000007FF25F196C8 select * from deptx where deptno=10 1 0 0 000007FF25F18160 000007FF25F18D48 4072 12144 3117 19333 19333 692228807 07447rnnn54q7 0
父遊標控制程式碼地址 000007FF25F196C8 000007FF25F196C8 select * from deptx where deptno=10 1 0 0 000007FF25F19610 00 4072 0 0 4072 4072 692228807 07447rnnn54q7 65535
--//V$OPEN_CURSOR.ADDRESS=000007FF25F196C8 對應父遊標控制程式碼地址.
--//V$OPEN_CURSOR.CHILD_ADDRES=000007FF25F18218,對應子游標控制程式碼地址.
3.繼續測試:
--//session 1:
SCOTT@test01p> alter session set optimizer_index_caching=100;
Session altered.
--//修改會話引數optimizer_index_caching=100,這樣游標不再共享,必須生成新的子游標.
select * from deptx where deptno=10;
select * from deptx where deptno=10;
select * from deptx where deptno=10;
select * from deptx where deptno=10;
--//session 2:
SYS@test> select * from V$OPEN_CURSOR where sid=234 and sql_id='07447rnnn54q7';
SADDR SID USER_NAME ADDRESS HASH_VALUE SQL_ID SQL_TEXT LAST_SQL_ACTIVE_TIM SQL_EXEC_ID CURSOR_TYPE CHILD_ADDRESS CON_ID
---------------- --- --------- ---------------- ---------- ------------- ------------------------------------ ------------------- ----------- --------------------- ---------------- ------
000007FF312D41D8 234 SCOTT 000007FF25F196C8 692228807 07447rnnn54q7 select * from deptx where deptno=10 SESSION CURSOR CACHED 000007FF25F18218 3
000007FF312D41D8 234 SCOTT 000007FF25F196C8 692228807 07447rnnn54q7 select * from deptx where deptno=10 SESSION CURSOR CACHED 000007FF28E627F8 3
--//可以發現同一個會話,相同的sql語句可以快取2個遊標.我一直以為僅僅快取1個.看來親自測試很有必要.
SYS@test> @ sharepool/shp4 07447rnnn54q7 0
TEXT KGLHDADR KGLHDPAR C40 KGLHDLMD KGLHDPMD KGLHDIVC KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 N0_6_16 N20 KGLNAHSH KGLOBT03 KGLOBT09
-------------- ---------------- ---------------- ---------------------------------------- ---------- ---------- ---------- ---------------- ---------------- ---------- ---------- ---------- --------- ---------- ---------- ------------- ----------
子游標控制程式碼地址 000007FF25F18218 000007FF25F196C8 select * from deptx where deptno=10 0 0 0 000007FF25F18160 000007FF25F18D48 4072 12144 4565 20781 20781 692228807 07447rnnn54q7 0
子游標控制程式碼地址 000007FF28E627F8 000007FF25F196C8 select * from deptx where deptno=10 1 0 0 000007FF241136C0 000007FF2420BAF8 4072 12144 4565 20781 20781 692228807 07447rnnn54q7 1
父遊標控制程式碼地址 000007FF25F196C8 000007FF25F196C8 select * from deptx where deptno=10 1 0 0 000007FF25F19610 00 4072 0 0 4072 4072 692228807 07447rnnn54q7 65535
--//V$OPEN_CURSOR.ADDRESS=000007FF25F196C8 對應父遊標控制程式碼地址.
--//V$OPEN_CURSOR.CHILD_ADDRES=000007FF25F18218,對應子游標控制程式碼地址(KGLOBT09=0)
--//V$OPEN_CURSOR.CHILD_ADDRES=000007FF28E627F8,對應子游標控制程式碼地址(KGLOBT09=1).
--//順便說一下x$kglob.KGLOBT09 對應的就是child number號.x$kglob.KGLOBT09=65535就是父遊標.
--//可以發現當執行3次以上快取遊標後,實際上類似建立一種快捷方式,直接能定位到子游標控制程式碼地址,
--//有一些文章提到可以定位子游標控制程式碼堆6,執行獲得執行計劃.避免一些latch以及metux的操作.
--//也就是軟軟解析.
--//另外如果已經快取的遊標,新開啟的回話第一次執行也是軟解析,因為執行前V$OPEN_CURSOR檢視在當前sid下沒有記錄.
--//再次執行才是軟軟解析.
--//重新整理共享池重複測試:
--//session 1:
SCOTT@test01p> @spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- -------------------- ------- ---------- -----------------------------------------------
152 9 5460:4376 DEDICATED 5564 22 5 alter system kill session '152,9' immediate;
select * from deptx where deptno=10;
select * from deptx where deptno=10;
select * from deptx where deptno=10;
select * from deptx where deptno=10;
select * from deptx where deptno=10;
--//確定sql_id=07447rnnn54q7.
--//session 2:
SYS@test01p> select * from V$OPEN_CURSOR where sid=152 and sql_id='07447rnnn54q7';
SADDR SID USER_NAME ADDRESS HASH_VALUE SQL_ID SQL_TEXT LAST_SQL_ACTIVE_TIM SQL_EXEC_ID CURSOR_TYPE CHILD_ADDRESS CON_ID
---------------- --- --------- ---------------- ---------- ------------- ------------------------------------ ------------------- ----------- --------------------- ---------------- ------
000007FF312547D8 152 SCOTT 000007FF23E1CC60 692228807 07447rnnn54q7 select * from deptx where deptno=10 SESSION CURSOR CACHED 000007FF257BA640 3
SYS@test01p> @ sharepool/shp4 07447rnnn54q7 0
TEXT KGLHDADR KGLHDPAR C40 KGLHDLMD KGLHDPMD KGLHDIVC KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 N0_6_16 N20 KGLNAHSH KGLOBT03 KGLOBT09
-------------- ---------------- ---------------- ---------------------------------------- ---------- ---------- ---------- ---------------- ---------------- ---------- ---------- ---------- --------- ---------- ---------- ------------- ----------
子游標控制程式碼地址 000007FF257BA640 000007FF23E1CC60 select * from deptx where deptno=10 1 0 0 000007FF1F2CCAE0 000007FF2554B638 4072 12144 3117 19333 19333 692228807 07447rnnn54q7 0
父遊標控制程式碼地址 000007FF23E1CC60 000007FF23E1CC60 select * from deptx where deptno=10 1 0 0 000007FF1FD5C898 00 4072 0 0 4072 4072 692228807 07447rnnn54q7 65535
--//session 3:
SCOTT@test01p> @spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- -------------------- ------- ---------- --------------------------------------------------
13 157 2340:2536 DEDICATED 4428 56 4 alter system kill session '13,157' immediate;
--//session 2:
SYS@test01p> select * from V$OPEN_CURSOR where sid=13 and sql_id='07447rnnn54q7';
no rows selected
--//sid=13 還沒有快取游標.
--//session 3:
SCOTT@test01p> select * from deptx where deptno=10;
DEPTNO DNAME LOC
---------- -------------------- -------------
10 ACCOUNTING NEW YORK
SCOTT@test01p> select sysdate from dual ;
SYSDATE
-------------------
2018-09-07 22:18:02
--//session 2:
SYS@test01p> select * from V$OPEN_CURSOR where sql_id='07447rnnn54q7';
SADDR SID USER_NAME ADDRESS HASH_VALUE SQL_ID SQL_TEXT LAST_SQL_ACTIVE_TIM SQL_EXEC_ID CURSOR_TYPE CHILD_ADDRESS CON_ID
---------------- --- --------- ---------------- ---------- ------------- ------------------------------------ ------------------- ----------- ------------------------------- ---------------- ------
000007FF31123630 13 SCOTT 000007FF23E1CC60 692228807 07447rnnn54q7 select * from deptx where deptno=10 DICTIONARY LOOKUP CURSOR CACHED 000007FF257BA640 3
000007FF312547D8 152 SCOTT 000007FF23E1CC60 692228807 07447rnnn54q7 select * from deptx where deptno=10 SESSION CURSOR CACHED 000007FF257BA640 3
--//可以發現會話sid=13(session 3)當前的CURSOR_TYPE='DICTIONARY LOOKUP CURSOR CACHED'.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2213822/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 同一會話中的多個 WebRequest會話Web
- [20180627]測試bbed是否支援管道命令.txt
- [20210429]檔案頭塊不會快取.txt快取
- [20190211]簡單測試埠是否開啟.txt
- 三句話測試你是否懂gitGit
- [20190211]簡單測試埠是否開啟(補充).txt
- [20210202]計算標量子查詢快取數量2.txt快取
- [20230510]測試使用tpt ddl指令碼是否產生日誌.txt指令碼
- Laravel 啟用多個 work 對同一個佇列進行處理的時候是否會出現同步執行Laravel佇列
- 白話分散式儲存測試(一)明確測試目標分散式
- [20210201]19c計算標量子查詢快取數量.txt快取
- [20210812]測試sql語句子游標的效能.txtSQL
- 【專項測試系列】-快取擊穿、穿透、雪崩專項測試快取穿透
- opencv-python 讀取同一目錄的多個檔案OpenCVPython
- php 快取使用監控測試程式碼PHP快取
- 大話效能測試系列(1)- 效能測試概念與主要指標指標
- 同一臺手機安裝同一個應用的測試版,正式版
- screen 命令示例:管理多個終端會話會話
- 測試標題測試標題
- 儲存過程定義多個遊標多個begin儲存過程
- Spring Boot中使用TestContainer測試快取機制Spring BootAI快取
- 面試總結 —— Redis “快取穿透”、“快取擊穿”、“快取雪崩”面試Redis快取穿透
- 大話效能測試系列(3)- 常用的效能指標指標
- 手工電子面單-批量儲存同一個收貨地址的多個包裹資訊
- [20210816]測試sql語句子游標的效能3.txtSQL
- [20210818]測試sql語句子游標的效能4.txtSQL
- [20181119]firefox更改快取資料夾.txtFirefox快取
- [20180724]Flashback query和子游標共享.txt
- 使用 Infinispan 快取功能支援多個 Redis 資料庫快取Redis資料庫
- 面試官:快取穿透、快取雪崩和快取擊穿是什麼?面試快取穿透
- Redis 面試常見問題———快取雪崩、快取擊穿以及快取穿透Redis面試快取穿透
- 不廢話,程式碼實踐帶你掌握 強快取、協商快取!快取
- k05_多級快取快取
- 多級快取架構(六)快取架構
- QPS這麼高,那就來寫個多級快取吧快取
- 同一個元素中有多個class,優先順序
- python多個txt合併Python
- 同一頁面生成多個驗證碼