20151223關於共享池4x-SQL記憶體結構父子游標
[20151223]關於共享池4x-SQL記憶體結構父子游標.txt
--重複測試:http://blog.itpub.net/267265/viewspace-1436541/
--這個主要和recr和freeabl類似.
--1.節約記憶體
--2.減少檢索連結串列的時間.
--3.oracle的演算法規定,sql語句必須至少是一父一子的情況.很多情況下都是一父多子.也就是說,每個遊標,oracle都會為它設定個父遊標
-- 如果有sql文字相同,但無法共享執行計劃的情況出現,那就會出現一父多子的情況.
--注意除了sql物件,共享池中其它型別的物件都沒有父子游標的概念.
--自己按照的介紹,重複測試一遍,加強理解,以前做個1次10g,今天補充11g的。
1.測試環境:
SCOTT@book> @ &r/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
SCOTT@book> select * from dept where deptno=10;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
--sql_id=4xamnunv51w9j
2.--父遊標控制程式碼:
$ cat shp4.sql
SELECT DECODE (kglhdadr,
kglhdpar, '父遊標控制程式碼地址',
'子游標控制程式碼地址')
text,
kglhdadr,
kglhdpar,
substr(kglnaobj,1,40) c40,
kglobhd0,
kglobhd6,
kglobhs0,kglobhs6,kglobt16,
kglobhs0+kglobhs6+kglobt16,
kglobhs0+kglobhs1+kglobhs2+kglobhs3+kglobhs4+kglobhs5+kglobhs6+kglobt16 N20,
kglnahsh,
kglobt03
FROM x$kglob
WHERE kglobt03 = '&1' or kglhdpar='&1' or kglhdadr='&1';
SYS@book> @ &r/sharepool/shp4.sql 4xamnunv51w9j
TEXT KGLHDADR KGLHDPAR C40 KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 KGLOBHS0+KGLOBHS6+KGLOBT16 N20 KGLNAHSH KGLOBT03
-------------- ---------------- ---------------- ---------------------------------------- ---------------- ---------------- ---------- ---------- ---------- -------------------------- ---------- ---------- -------------
子游標控制程式碼地址 000000007C09AA80 0000000061B19120 select * from dept where deptno=10 0000000061B19060 0000000062B4F770 4488 12144 3067 19699 19699 911274289 4xamnunv51w9j
父遊標控制程式碼地址 0000000061B19120 0000000061B19120 select * from dept where deptno=10 000000007C04C190 00 4720 0 0 4720 4720 911274289 4xamnunv51w9j
--可以發現KGLHDADR=0000000061B19120是父遊標控制程式碼地址,直接使用它查詢x$ksmsp的ksmchptr是不行的.存在一個偏移量
--正常是偏移0x30(48位元組)是父遊標控制程式碼開始的chunk地址(0000000061B190F0):
SYS@book> select * from x$ksmsp where ksmchptr='0000000061B190F0';
ADDR INDX INST_ID KSMCHIDX KSMCHDUR KSMCHCOM KSMCHPTR KSMCHSIZ KSMCHCLS KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00007F5BF48ED4D0 16220 1 1 2 KGLHD 0000000061B190F0 560 recr 80 00
select * from x$ksmsp where ksmchptr in (
SELECT x
FROM (SELECT a.ksmchptr, lag (a.ksmchptr, 1) OVER (ORDER BY a.ksmchptr) x
FROM x$ksmsp a )
WHERE '0000000061B19120' between x and ksmchptr);
--或者
SELECT * FROM x$ksmsp WHERE TO_NUMBER ('&1', 'xxxxxxxxxxxxxxxx') between TO_NUMBER(KSMCHPTR, 'xxxxxxxxxxxxxxxx') and TO_NUMBER(KSMCHPTR, 'xxxxxxxxxxxxxxxx')+KSMCHSIZ;
ADDR INDX INST_ID KSMCHIDX KSMCHDUR KSMCHCOM KSMCHPTR KSMCHSIZ KSMCHCLS KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00007F5BF461D840 16274 1 1 2 KGLHD 0000000061B190F0 560 recr 80 00
--從父遊標控制程式碼裡面可以發現執行sql的文字.
--另外可以發現父遊標控制程式碼的chunk型別是recr.大小560位元組.
3.SQL的chunk:父遊標堆0:
--父遊標控制程式碼地址 KGLOBHD0='000000007C04C190'
--注意父遊標控制程式碼地址那行:KGLOBHD0 = 000000007C04C190 就是父遊標堆0描述符(DS)地址.
new 1: select a.*,dump(a.KSMCHCOM,16) c60 from x$ksmsp a where a.ksmchpar='000000007C04C190'
ADDR INDX INST_ID KSMCHIDX KSMCHDUR KSMCHCOM KSMCHPTR KSMCHSIZ KSMCHCLS KSMCHTYP KSMCHPAR C60
---------------- ---------- ---------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ---------------- ------------------------------------------------------------
00007F5BF497B028 6531 1 1 3 KGLH0^3650f131 0000000062B4F000 4096 recr 4095 000000007C04C190 Typ=1 Len=14: 4b,47,4c,48,30,5e,33,36,35,30,66,31,33,31
--可以發現父遊標堆0的chunk有1個,型別是recr型別,大小4096.
4.SQL的chunk:父遊標堆0的DS:
--再來看看父遊標堆0描述符(DS)地址 000000007C04C190
SELECT * FROM x$ksmsp WHERE TO_NUMBER ('&1', 'xxxxxxxxxxxxxxxx') between TO_NUMBER(KSMCHPTR, 'xxxxxxxxxxxxxxxx') and TO_NUMBER(KSMCHPTR, 'xxxxxxxxxxxxxxxx')+KSMCHSIZ;
ADDR INDX INST_ID KSMCHIDX KSMCHDUR KSMCHCOM KSMCHPTR KSMCHSIZ KSMCHCLS KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00007F5BF49F8610 14685 1 1 2 KGLDA 000000007C04C128 240 freeabl 0 00
--父遊標堆0的DS. chunk是freeable型別.大小240.
5.SQL的chunk:子游標控制程式碼:
SYS@book> @ &r/sharepool/shp4.sql 4xamnunv51w9j
TEXT KGLHDADR KGLHDPAR C40 KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 KGLOBHS0+KGLOBHS6+KGLOBT16 N20 KGLNAHSH KGLOBT03
-------------- ---------------- ---------------- ---------------------------------------- ---------------- ---------------- ---------- ---------- ---------- -------------------------- ---------- ---------- -------------
子游標控制程式碼地址 000000007C09AA80 0000000061B19120 select * from dept where deptno=10 0000000061B19060 0000000062B4F770 4488 12144 3067 19699 19699 911274289 4xamnunv51w9j
父遊標控制程式碼地址 0000000061B19120 0000000061B19120 select * from dept where deptno=10 000000007C04C190 00 4720 0 0 4720 4720 911274289 4xamnunv51w9j
--子游標控制程式碼地址 KGLHDADR=000000007C09AA80
new 1: SELECT * FROM x$ksmsp WHERE TO_NUMBER ('000000007C09AA80', 'xxxxxxxxxxxxxxxx') between TO_NUMBER(KSMCHPTR, 'xxxxxxxxxxxxxxxx') and TO_NUMBER(KSMCHPTR, 'xxxxxxxxxxxxxxxx')+KSMCHSIZ
ADDR INDX INST_ID KSMCHIDX KSMCHDUR KSMCHCOM KSMCHPTR KSMCHSIZ KSMCHCLS KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00007F5BF49DAA08 14144 1 1 2 KGLHD 000000007C09AA50 368 recr 80 00
--偏移0x30(48位元組),猜測還是正確的。
--另外可以發現子游標控制程式碼的chunk型別是recr.大小368位元組.
6.SQL的chunk:子游標堆0:
SYS@book> @ &r/sharepool/shp4.sql 4xamnunv51w9j
TEXT KGLHDADR KGLHDPAR C40 KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 KGLOBHS0+KGLOBHS6+KGLOBT16 N20 KGLNAHSH KGLOBT03
-------------- ---------------- ---------------- ---------------------------------------- ---------------- ---------------- ---------- ---------- ---------- -------------------------- ---------- ---------- -------------
子游標控制程式碼地址 000000007C09AA80 0000000061B19120 select * from dept where deptno=10 0000000061B19060 0000000062B4F770 4528 12144 3067 19739 19739 911274289 4xamnunv51w9j
父遊標控制程式碼地址 0000000061B19120 0000000061B19120 select * from dept where deptno=10 000000007C04C190 00 4720 0 0 4720 4720 911274289 4xamnunv51w9j
--注意子游標控制程式碼地址那行:
KGLOBHD0=0000000061B19060,就是子游標堆0描述符(DS)地址.
KGLOBHD6=0000000062B4F770,就是子游標堆6描述符(DS)地址.
new 1: select a.*,dump(a.KSMCHCOM,16) c60 from x$ksmsp a where a.ksmchpar='0000000061B19060'
ADDR INDX INST_ID KSMCHIDX KSMCHDUR KSMCHCOM KSMCHPTR KSMCHSIZ KSMCHCLS KSMCHTYP KSMCHPAR C60
---------------- ---------- ---------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ---------------- ------------------------------------------------------------
00007F5BF49651A8 6625 1 1 3 KGLH0^3650f131 0000000062B4E000 4096 recr 4095 0000000061B19060 Typ=1 Len=14: 4b,47,4c,48,30,5e,33,36,35,30,66,31,33,31
--可以發現子游標堆0的chunk有1個,1個是recr型別,大小4096.
7.SQL的chunk:子游標堆0的DS:
SYS@book> @ &r/sharepool/shp4.sql 4xamnunv51w9j
TEXT KGLHDADR KGLHDPAR C40 KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 KGLOBHS0+KGLOBHS6+KGLOBT16 N20 KGLNAHSH KGLOBT03
-------------- ---------------- ---------------- ---------------------------------------- ---------------- ---------------- ---------- ---------- ---------- -------------------------- ---------- ---------- -------------
子游標控制程式碼地址 000000007C09AA80 0000000061B19120 select * from dept where deptno=10 0000000061B19060 0000000062B4F770 4528 12144 3067 19739 19739 911274289 4xamnunv51w9j
父遊標控制程式碼地址 0000000061B19120 0000000061B19120 select * from dept where deptno=10 000000007C04C190 00 4720 0 0 4720 4720 911274289 4xamnunv51w9j
--注意子游標控制程式碼地址 KGLOBHD0=0000000061B19060
new 1: SELECT * FROM x$ksmsp WHERE TO_NUMBER ('0000000061B19060', 'xxxxxxxxxxxxxxxx') between TO_NUMBER(KSMCHPTR, 'xxxxxxxxxxxxxxxx') and TO_NUMBER(KSMCHPTR, 'xxxxxxxxxxxxxxxx')+KSMCHSIZ
ADDR INDX INST_ID KSMCHIDX KSMCHDUR KSMCHCOM KSMCHPTR KSMCHSIZ KSMCHCLS KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00007F5BF4A33438 16536 1 1 2 KGLDA 0000000061B18FF8 248 freeabl 0 00
--可以發現子游標堆0的堆描述符在KSMCHPTR=0000000061B18FF8的chunk。
--子游標堆0的DS. chunk是freeable型別.大小248.
8.SQL的chunk:子游標堆6:
SYS@book> @ &r/sharepool/shp4.sql 4xamnunv51w9j
old 16: WHERE kglobt03 = '&1' or kglhdpar='&1' or kglhdadr='&1'
new 16: WHERE kglobt03 = '4xamnunv51w9j' or kglhdpar='4xamnunv51w9j' or kglhdadr='4xamnunv51w9j'
TEXT KGLHDADR KGLHDPAR C40 KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 KGLOBHS0+KGLOBHS6+KGLOBT16 N20 KGLNAHSH KGLOBT03
-------------- ---------------- ---------------- ---------------------------------------- ---------------- ---------------- ---------- ---------- ---------- -------------------------- ---------- ---------- -------------
子游標控制程式碼地址 000000007C09AA80 0000000061B19120 select * from dept where deptno=10 0000000061B19060 0000000062B4F770 4528 12144 3067 19739 19739 911274289 4xamnunv51w9j
父遊標控制程式碼地址 0000000061B19120 0000000061B19120 select * from dept where deptno=10 000000007C04C190 00 4720 0 0 4720 4720 911274289 4xamnunv51w9j
--注意子游標控制程式碼地址 堆6的DS地址:KGLOBHD6=0000000062B4F770.
new 1: select a.*,dump(a.KSMCHCOM,16) c60 from x$ksmsp a where a.ksmchpar='0000000062B4F770'
ADDR INDX INST_ID KSMCHIDX KSMCHDUR KSMCHCOM KSMCHPTR KSMCHSIZ KSMCHCLS KSMCHTYP KSMCHPAR C60
---------------- ---------- ---------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ---------------- ------------------------------------------------------------
00007F5BF49A5FB0 3487 1 1 4 SQLA^3650f131 00000000623956C8 4096 recr 4095 0000000062B4F770 Typ=1 Len=13: 53,51,4c,41,5e,33,36,35,30,66,31,33,31
00007F5BF49A5F58 3488 1 1 4 SQLA^3650f131 00000000623946C8 4096 freeabl 0 0000000062B4F770 Typ=1 Len=13: 53,51,4c,41,5e,33,36,35,30,66,31,33,31
00007F5BF49A7EE8 3489 1 1 4 SQLA^3650f131 00000000623936C8 4096 freeabl 0 0000000062B4F770 Typ=1 Len=13: 53,51,4c,41,5e,33,36,35,30,66,31,33,31
--可以發現子游標堆6的chunk有3個,1個是recr型別,2個freeabl型別,大小4096.
--可以發現執行計劃在堆6中,型別freeabl。
9.SQL的chunk:子游標堆6的DS:
SYS@book> @ &r/sharepool/shp4.sql 4xamnunv51w9j
old 16: WHERE kglobt03 = '&1' or kglhdpar='&1' or kglhdadr='&1'
new 16: WHERE kglobt03 = '4xamnunv51w9j' or kglhdpar='4xamnunv51w9j' or kglhdadr='4xamnunv51w9j'
TEXT KGLHDADR KGLHDPAR C40 KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 KGLOBHS0+KGLOBHS6+KGLOBT16 N20 KGLNAHSH KGLOBT03
-------------- ---------------- ---------------- ---------------------------------------- ---------------- ---------------- ---------- ---------- ---------- -------------------------- ---------- ---------- -------------
子游標控制程式碼地址 000000007C09AA80 0000000061B19120 select * from dept where deptno=10 0000000061B19060 0000000062B4F770 4528 12144 3067 19739 19739 911274289 4xamnunv51w9j
父遊標控制程式碼地址 0000000061B19120 0000000061B19120 select * from dept where deptno=10 000000007C04C190 00 4720 0 0 4720 4720 911274289 4xamnunv51w9j
--注意子游標控制程式碼地址 堆6的DS地址:KGLOBHD6=0000000062B4F770.
new 1: SELECT * FROM x$ksmsp WHERE TO_NUMBER ('0000000062B4F770', 'xxxxxxxxxxxxxxxx') between TO_NUMBER(KSMCHPTR, 'xxxxxxxxxxxxxxxx') and TO_NUMBER(KSMCHPTR, 'xxxxxxxxxxxxxxxx')+KSMCHSIZ
ADDR INDX INST_ID KSMCHIDX KSMCHDUR KSMCHCOM KSMCHPTR KSMCHSIZ KSMCHCLS KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00007F5BF4956D18 6898 1 1 3 KGLH0^3650f131 0000000062B4F000 4096 recr 4095 000000007C04C190
--注意父遊標控制程式碼地址那行:KGLOBHD0 = 000000007C04C190 就是父遊標堆0描述符(DS)地址.
--可以發現子游標堆6描述符(DS)地址在 父遊標的堆0中。
10.做一個總結畫圖不是很方便,列出來:
父遊標控制程式碼的chunk型別是recr.大小560位元組.
父遊標堆0的chunk有1個recr型別,大小4096.
父遊標堆0的DS. chunk是freeable型別.大小240.
--父遊標 需要3個chunk,2個型別recr,1個型別freeabl。
子游標控制程式碼的chunk型別是recr.大小368位元組.
子游標堆0的chunk有1個recr型別,大小4096.
子游標堆0的DS. chunk是freeable型別.大小248.
子游標堆6的chunk有3個,1個是recr型別,2個freeabl型別,大小4096.
子游標堆6的DS 在父遊標的堆0中(不做計算)。型別freeabl。
--子游標 需要6個chunk,3個型別recr,3個型別freeabl。
--總共9個chunk。5個型別recr,4個型別freeabl。這個測試與vaga的測試一致。
11.佔用共享池的大小:
SYS@book> select SHARABLE_MEM from v$sql where sql_id='4xamnunv51w9j';
SHARABLE_MEM
------------
19739
SYS@book> select SHARABLE_MEM from v$sqlarea where sql_id='4xamnunv51w9j';
SHARABLE_MEM
------------
19739
SYS@book> @&r/sharepool/shp4 4xamnunv51w9j
TEXT KGLHDADR KGLHDPAR C40 KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 KGLOBHS0+KGLOBHS6+KGLOBT16 N20 KGLNAHSH KGLOBT03
-------------- ---------------- ---------------- ---------------------------------------- ---------------- ---------------- ---------- ---------- ---------- -------------------------- ---------- ---------- -------------
子游標控制程式碼地址 000000007C09AA80 0000000061B19120 select * from dept where deptno=10 0000000061B19060 0000000062B4F770 4528 12144 3067 19739 19739 911274289 4xamnunv51w9j
父遊標控制程式碼地址 0000000061B19120 0000000061B19120 select * from dept where deptno=10 000000007C04C190 00 4720 0 0 4720 4720 911274289 4xamnunv51w9j
--對比可以發現與查詢x$kglob的子游標控制程式碼地址那行KGLOBHS0+KGLOBHS6+KGLOBT16一致。也就是v$sql檢視佔用SHARABLE_MEM記憶體不計算父遊標。
--按照上面的計算 子游標 368+4096+248+3*4096=17000
--可以發現查詢的基表是 x$kglcursor_child,而SHARABLE_MEM 對應的是kglobhs0+kglobhs1+kglobhs2+kglobhs3+kglobhs4+kglobhs5+kglobhs6+kglobt16。
--因為其它的值是0,所以兩者是相等的。
--可以發現這樣1條sql語句需要佔用16K上下,如果在oltp系統沒有使用繫結,消耗共享記憶體很大的,而且導致共享記憶體出現大量碎片,
--管理帶來困難,非常容易觸發ora-4031錯誤。
12.重新整理共享池看看:
SYS@book> @&r/sharepool/shp4 4xamnunv51w9j
TEXT KGLHDADR KGLHDPAR C40 KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 KGLOBHS0+KGLOBHS6+KGLOBT16 N20 KGLNAHSH KGLOBT03
-------------- ---------------- ---------------- ---------------------------------------- ---------------- ---------------- ---------- ---------- ---------- -------------------------- ---------- ---------- -------------
子游標控制程式碼地址 000000007C09AA80 0000000061B19120 select * from dept where deptno=10 0000000061B19060 0000000062B4F770 4528 12144 3067 19739 19739 911274289 4xamnunv51w9j
父遊標控制程式碼地址 0000000061B19120 0000000061B19120 select * from dept where deptno=10 000000007C04C190 00 4720 0 0 4720 4720 911274289 4xamnunv51w9j
SYS@book> alter system flush shared_pool;
System altered.
SYS@book> @&r/sharepool/shp4 4xamnunv51w9j
old 16: WHERE kglobt03 = '&1' or kglhdpar='&1' or kglhdadr='&1'
new 16: WHERE kglobt03 = '4xamnunv51w9j' or kglhdpar='4xamnunv51w9j' or kglhdadr='4xamnunv51w9j'
TEXT KGLHDADR KGLHDPAR C40 KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 KGLOBHS0+KGLOBHS6+KGLOBT16 N20 KGLNAHSH KGLOBT03
-------------- ---------------- ---------------- ---------------------------------------- ---------------- ---------------- ---------- ---------- ---------- -------------------------- ---------- ---------- -------------
子游標控制程式碼地址 000000007C09AA80 0000000061B19120 select * from dept where deptno=10 00 00 0 0 3067 3067 3067 911274289 4xamnunv51w9j
父遊標控制程式碼地址 0000000061B19120 0000000061B19120 select * from dept where deptno=10 000000007C04C190 00 4720 0 0 4720 4720 911274289 4xamnunv51w9j
--可以發現父遊標佔用記憶體沒有回收,僅僅回收了大部分子游標占用記憶體。
--注意看子游標控制程式碼地址 那行,KGLOBHD0 KGLOBHD6 =0 ,也就是清除了子游標的堆0與堆6. 子游標控制程式碼沒有清除。
--再次執行一次查詢:
SCOTT@book> select * from dept where deptno=10;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
SYS@book> @&r/sharepool/shp4 4xamnunv51w9j
old 16: WHERE kglobt03 = '&1' or kglhdpar='&1' or kglhdadr='&1'
new 16: WHERE kglobt03 = '4xamnunv51w9j' or kglhdpar='4xamnunv51w9j' or kglhdadr='4xamnunv51w9j'
TEXT KGLHDADR KGLHDPAR C40 KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 KGLOBHS0+KGLOBHS6+KGLOBT16 N20 KGLNAHSH KGLOBT03
-------------- ---------------- ---------------- ---------------------------------------- ---------------- ---------------- ---------- ---------- ---------- -------------------------- ---------- ---------- -------------
子游標控制程式碼地址 000000007C09AA80 0000000061B19120 select * from dept where deptno=10 00000000850A5068 0000000062B4F770 4488 12144 3067 19699 19699 911274289 4xamnunv51w9j
父遊標控制程式碼地址 0000000061B19120 0000000061B19120 select * from dept where deptno=10 000000007C04C190 00 4720 0 0 4720 4720 911274289 4xamnunv51w9j
13.繼續如果再產生一個子游標呢?
SCOTT@book> alter session set optimizer_index_caching =10;
Session altered.
SCOTT@book> select * from dept where deptno=10;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
SYS@book> @&r/sharepool/shp4 4xamnunv51w9j
old 16: WHERE kglobt03 = '&1' or kglhdpar='&1' or kglhdadr='&1'
new 16: WHERE kglobt03 = '4xamnunv51w9j' or kglhdpar='4xamnunv51w9j' or kglhdadr='4xamnunv51w9j'
TEXT KGLHDADR KGLHDPAR C40 KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 KGLOBHS0+KGLOBHS6+KGLOBT16 N20 KGLNAHSH KGLOBT03
-------------- ---------------- ---------------- ---------------------------------------- ---------------- ---------------- ---------- ---------- ---------- -------------------------- ---------- ---------- -------------
子游標控制程式碼地址 000000007C09AA80 0000000061B19120 select * from dept where deptno=10 00000000850A5068 0000000062B4F770 4488 12144 4347 20979 20979 911274289 4xamnunv51w9j
子游標控制程式碼地址 000000007C1BC238 0000000061B19120 select * from dept where deptno=10 000000007C376CC8 0000000062B4FD38 4504 12144 4347 20995 20995 911274289 4xamnunv51w9j
父遊標控制程式碼地址 0000000061B19120 0000000061B19120 select * from dept where deptno=10 000000007C04C190 00 4720 0 0 4720 4720 911274289 4xamnunv51w9j
--可以發現如果語句不能共享,再產生新子游標。
--並且每個子游標占用的記憶體增加了,不知道為什麼?KGLOBT16部分增加了。
--注意增加的一行 子游標控制程式碼地址 堆6的DS地址:KGLOBHD6=0000000062B4FD38
new 1: SELECT * FROM x$ksmsp WHERE TO_NUMBER ('0000000062B4FD38', 'xxxxxxxxxxxxxxxx') between TO_NUMBER(KSMCHPTR, 'xxxxxxxxxxxxxxxx') and TO_NUMBER(KSMCHPTR, 'xxxxxxxxxxxxxxxx')+KSMCHSIZ
ADDR INDX INST_ID KSMCHIDX KSMCHDUR KSMCHCOM KSMCHPTR KSMCHSIZ KSMCHCLS KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00007F5BF49826E0 7986 1 1 3 KGLH0^3650f131 0000000062B4F000 4096 recr 4095 000000007C04C190
--注意父遊標控制程式碼地址那行:KGLOBHD0 = 000000007C04C190 就是父遊標堆0描述符(DS)地址.
--可以發現子游標堆6描述符(DS)地址在 父遊標的堆0中。
14.退出執行的會話在重新整理看看:
SYS@book> @&r/sharepool/shp4 4xamnunv51w9j
old 16: WHERE kglobt03 = '&1' or kglhdpar='&1' or kglhdadr='&1'
new 16: WHERE kglobt03 = '4xamnunv51w9j' or kglhdpar='4xamnunv51w9j' or kglhdadr='4xamnunv51w9j'
TEXT KGLHDADR KGLHDPAR C40 KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 KGLOBHS0+KGLOBHS6+KGLOBT16 N20 KGLNAHSH KGLOBT03
-------------- ---------------- ---------------- ---------------------------------------- ---------------- ---------------- ---------- ---------- ---------- -------------------------- ---------- ---------- -------------
子游標控制程式碼地址 000000007C09AA80 0000000061B19120 select * from dept where deptno=10 00000000850A5068 0000000062B4F770 4488 12144 4347 20979 20979 911274289 4xamnunv51w9j
子游標控制程式碼地址 000000007C1BC238 0000000061B19120 select * from dept where deptno=10 000000007C376CC8 0000000062B4FD38 4504 12144 4347 20995 20995 911274289 4xamnunv51w9j
父遊標控制程式碼地址 0000000061B19120 0000000061B19120 select * from dept where deptno=10 000000007C04C190 00 4720 0 0 4720 4720 911274289 4xamnunv51w9j
SYS@book> alter system flush shared_pool ;
System altered.
SYS@book> @&r/sharepool/shp4 4xamnunv51w9j
old 16: WHERE kglobt03 = '&1' or kglhdpar='&1' or kglhdadr='&1'
new 16: WHERE kglobt03 = '4xamnunv51w9j' or kglhdpar='4xamnunv51w9j' or kglhdadr='4xamnunv51w9j'
no rows selected
--可以發現僅僅在執行該語句的會話退出後,再重新整理共享池,該語句在共享池佔用的空間才消失。所以有時候重新整理並不能有效的回收共享
--池記憶體,要臨時解決ora-4031錯誤,要kill或者退出一組相似的應用,再重新整理效果才比較好。
--研究這東西太累!!
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-1877966/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 1224關於共享池4SQL記憶體結構父子游標補充SQL記憶體
- 1229關於共享池4-SQL記憶體結構父子游標補充3SQL記憶體
- 20150213關於共享池4-SQL記憶體結構父子游標SQL記憶體
- Oracle - 共享遊標、父子游標、硬軟解析Oracle
- 共享記憶體相關(ipcs/ipcrm)記憶體
- 記憶體結構記憶體
- 深入探究JVM之記憶體結構及字串常量池JVM記憶體字串
- iOS標準庫中常用資料結構和演算法之記憶體池iOS資料結構演算法記憶體
- 共享記憶體記憶體
- SGA與共享記憶體的關係記憶體
- 求助:關於linux下共享記憶體的問題(轉)Linux記憶體
- PostgreSQL:記憶體結構SQL記憶體
- oracle 記憶體結構Oracle記憶體
- JVM記憶體結構JVM記憶體
- Oracle體系結構之-記憶體結構Oracle記憶體
- 關於redis記憶體分析,記憶體優化Redis記憶體優化
- 資料庫體系結構-共享池(shared pool),largepool,Java池,流池資料庫Java
- Golang 共享記憶體Golang記憶體
- POSIX共享記憶體記憶體
- oracle 共享記憶體Oracle記憶體
- POSIX 共享記憶體記憶體
- 結構體記憶體對齊結構體記憶體
- Oracle記憶體體系結構Oracle記憶體
- 【基礎篇記憶體結構】oracle10g記憶體結構(一)記憶體Oracle
- GC最佳化:棧記憶體、span、NativeMemory、指標、池化記憶體 筆記GC記憶體指標筆記
- 2 Day DBA-管理Oracle例項-關於例項記憶體結構Oracle記憶體
- 關於autoreleasepool記憶體管理記憶體
- 關於記憶體錯誤記憶體
- 關於記憶體對齊記憶體
- oracle 記憶體結構(二)Oracle記憶體
- 調節記憶體結構記憶體
- Oracle 記憶體結構(一)Oracle記憶體
- ORACLE 記憶體結構理解.Oracle記憶體
- Oracle體系結構:記憶體結構和程式結構(轉)Oracle記憶體
- 共享池記憶體分配和錯誤ORA-00371記憶體
- 南大通用GBase 8s 共享記憶體結構概覽記憶體
- 記憶體池、程式池、執行緒池記憶體執行緒
- Oracle體系結構之記憶體結構(SGA、PGA)Oracle記憶體