[20180613]子游標不共享BIND_EQUIV_FAILURE
[20180613]子游標不共享BIND_EQUIV_FAILURE.txt
--//前幾天在測試函式與標量子查詢中雜湊表的數量時,遇到一個sql語句不能共享的問題,做一個記錄.
1.環境:
SYS@test> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- ----------------------------------------------------------------
x86_64/Linux 2.4.xx 10.2.0.4.0 Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
grant execute on sys.dbms_lock to scott;
CREATE OR REPLACE FUNCTION sleep1 (seconds IN NUMBER)
RETURN NUMBER
is
d_date date;
BEGIN
select sysdate into d_date from dual;
sys.dbms_lock.sleep(seconds/10);
RETURN seconds;
END;
/
CREATE OR REPLACE FUNCTION sleep (seconds IN NUMBER)
RETURN NUMBER
is
d_date date;
BEGIN
select sysdate into d_date from dual;
--//sys.dbms_lock.sleep(0.01);
RETURN seconds;
END;
/
create table t as select rownum id1,mod(rownum-1,20000)+1 id2 from dual connect by level<=40000;
2.建立測試指令碼:
--//建立指令碼by.txt:
set term off
alter session set statistics_level=all;
variable x number;
exec :x := &&1;
select t.*,(select sleep(id2) from dual) s from t where id2<=:x;
set term on
@ &r/dpc '' ''
quit
--//建立shell指令碼by.sh:
#! /bin/bash
# rm -f ez.txt
for i in $(seq 20000)
do
sqlplus -s -l scott/book @by.txt $i >> ez.txt
done
3.
--//完成過程中,可以發現sql語句select t.*,(select sleep(id2) from dual) s from t where id2<=:x;
--//產生大量子游標.隨著變數x變大.
SCOTT@book> @ &r/share 5sx5b8gvbkp29
SQL_TEXT = select t.*,(select sleep(id2) from dual) s from t where id2<=:x
SQL_ID = 5sx5b8gvbkp29
ADDRESS = 000000007B673FE8
CHILD_ADDRESS = 000000007D0E67C0
CHILD_NUMBER = 0
LOAD_OPTIMIZER_STATS = Y
REASON = <ChildNode><ChildNumber>0</ChildNumber><ID>40</ID><reason>Bind mismatch(25)</reason><size>0x0</size><details>extended_cursor_sharing</details></ChildNode>
--------------------------------------------------
SQL_TEXT = select t.*,(select sleep(id2) from dual) s from t where id2<=:x
SQL_ID = 5sx5b8gvbkp29
ADDRESS = 000000007B673FE8
CHILD_ADDRESS = 000000007DB06200
CHILD_NUMBER = 1
BIND_EQUIV_FAILURE = Y
REASON = <ChildNode><ChildNumber>1</ChildNumber><ID>40</ID><reason>Bind mismatch(33)</reason><size>1x4</size><init_ranges_in_first_pass>401504341</init_ranges_in_first_pass></ChildNode>
--------------------------------------------------
SQL_TEXT = select t.*,(select sleep(id2) from dual) s from t where id2<=:x
SQL_ID = 5sx5b8gvbkp29
ADDRESS = 000000007B673FE8
CHILD_ADDRESS = 000000007B4D2BC0
CHILD_NUMBER = 2
BIND_EQUIV_FAILURE = Y
REASON = <ChildNode><ChildNumber>2</ChildNumber><ID>40</ID><reason>Bind mismatch(33)</reason><size>1x4</size><init_ranges_in_first_pass>1324538965</init_ranges_in_first_pass></ChildNode>
--------------------------------------------------
SQL_TEXT = select t.*,(select sleep(id2) from dual) s from t where id2<=:x
SQL_ID = 5sx5b8gvbkp29
ADDRESS = 000000007B673FE8
CHILD_ADDRESS = 000000007D774F18
CHILD_NUMBER = 3
BIND_EQUIV_FAILURE = Y
REASON = <ChildNode><ChildNumber>3</ChildNumber><ID>40</ID><reason>Bind mismatch(33)</reason><size>1x4</size><init_ranges_in_first_pass>3389173190</init_ranges_in_first_pass></ChildNode>
--------------------------------------------------
SQL_TEXT = select t.*,(select sleep(id2) from dual) s from t where id2<=:x
SQL_ID = 5sx5b8gvbkp29
ADDRESS = 000000007B673FE8
CHILD_ADDRESS = 000000007C35B2F0
CHILD_NUMBER = 4
BIND_EQUIV_FAILURE = Y
REASON = <ChildNode><ChildNumber>4</ChildNumber><ID>40</ID><reason>Bind mismatch(33)</reason><size>1x4</size><init_ranges_in_first_pass>3251083087</init_ranges_in_first_pass></ChildNode>
--------------------------------------------------
SQL_TEXT = select t.*,(select sleep(id2) from dual) s from t where id2<=:x
SQL_ID = 5sx5b8gvbkp29
ADDRESS = 000000007B673FE8
CHILD_ADDRESS = 000000007DA931D0
CHILD_NUMBER = 5
BIND_EQUIV_FAILURE = Y
REASON = <ChildNode><ChildNumber>5</ChildNumber><ID>40</ID><reason>Bind mismatch(33)</reason><size>1x4</size><init_ranges_in_first_pass>1560069912</init_ranges_in_first_pass></ChildNode>
--------------------------------------------------
SQL_TEXT = select t.*,(select sleep(id2) from dual) s from t where id2<=:x
SQL_ID = 5sx5b8gvbkp29
ADDRESS = 000000007B673FE8
CHILD_ADDRESS = 000000007C23EDA8
CHILD_NUMBER = 6
BIND_EQUIV_FAILURE = Y
REASON = <ChildNode><ChildNumber>6</ChildNumber><ID>40</ID><reason>Bind mismatch(33)</reason><size>1x4</size><init_ranges_in_first_pass>2611100960</init_ranges_in_first_pass></ChildNode>
--------------------------------------------------
SQL_TEXT = select t.*,(select sleep(id2) from dual) s from t where id2<=:x
SQL_ID = 5sx5b8gvbkp29
ADDRESS = 000000007B673FE8
CHILD_ADDRESS = 000000007C623EC0
CHILD_NUMBER = 7
BIND_EQUIV_FAILURE = Y
REASON =
--------------------------------------------------
PL/SQL procedure successfully completed.
--//以上僅僅一部分.
$ grep SQL_ID ez.txt | uniq -c
522 SQL_ID 5sx5b8gvbkp29, child number 0
53 SQL_ID 5sx5b8gvbkp29, child number 1
58 SQL_ID 5sx5b8gvbkp29, child number 2
64 SQL_ID 5sx5b8gvbkp29, child number 3
70 SQL_ID 5sx5b8gvbkp29, child number 4
77 SQL_ID 5sx5b8gvbkp29, child number 5
85 SQL_ID 5sx5b8gvbkp29, child number 6
93 SQL_ID 5sx5b8gvbkp29, child number 7
103 SQL_ID 5sx5b8gvbkp29, child number 8
113 SQL_ID 5sx5b8gvbkp29, child number 9
124 SQL_ID 5sx5b8gvbkp29, child number 10
137 SQL_ID 5sx5b8gvbkp29, child number 11
150 SQL_ID 5sx5b8gvbkp29, child number 12
165 SQL_ID 5sx5b8gvbkp29, child number 13
182 SQL_ID 5sx5b8gvbkp29, child number 14
200 SQL_ID 5sx5b8gvbkp29, child number 15
220 SQL_ID 5sx5b8gvbkp29, child number 16
242 SQL_ID 5sx5b8gvbkp29, child number 17
266 SQL_ID 5sx5b8gvbkp29, child number 18
293 SQL_ID 5sx5b8gvbkp29, child number 19
322 SQL_ID 5sx5b8gvbkp29, child number 20
354 SQL_ID 5sx5b8gvbkp29, child number 21
390 SQL_ID 5sx5b8gvbkp29, child number 22
429 SQL_ID 5sx5b8gvbkp29, child number 23
472 SQL_ID 5sx5b8gvbkp29, child number 24
519 SQL_ID 5sx5b8gvbkp29, child number 25
571 SQL_ID 5sx5b8gvbkp29, child number 26
628 SQL_ID 5sx5b8gvbkp29, child number 27
691 SQL_ID 5sx5b8gvbkp29, child number 28
760 SQL_ID 5sx5b8gvbkp29, child number 29
836 SQL_ID 5sx5b8gvbkp29, child number 30
919 SQL_ID 5sx5b8gvbkp29, child number 31
1011 SQL_ID 5sx5b8gvbkp29, child number 32
1112 SQL_ID 5sx5b8gvbkp29, child number 33
1224 SQL_ID 5sx5b8gvbkp29, child number 34
1346 SQL_ID 5sx5b8gvbkp29, child number 35
1481 SQL_ID 5sx5b8gvbkp29, child number 36
1629 SQL_ID 5sx5b8gvbkp29, child number 37
1792 SQL_ID 5sx5b8gvbkp29, child number 0
297 SQL_ID 5sx5b8gvbkp29, child number 38
--//注前面第1列的數字是對於子游標執行的次數.
--//有點奇怪的地方是後面有1段執行的child number 0,共1792次.不知道為什麼.
$ grep SQL_ID ez.txt | uniq -c | cut -c1-8 | xargs | sed "s/ /+/g"|bc -l
20000
--//共執行20000次可以對上.
--//我決定再重複測試看看.修改如下:
#! /bin/bash
# rm -f ez.txt
for i in $(seq 20000)
do
sqlplus -s -l scott/book @by.txt $i >> fz.txt
done
--//輸出檔案換成fz.txt
$ grep SQL_ID fz.txt | uniq -c
500 SQL_ID 5sx5b8gvbkp29, child number 0
51 SQL_ID 5sx5b8gvbkp29, child number 1
56 SQL_ID 5sx5b8gvbkp29, child number 2
61 SQL_ID 5sx5b8gvbkp29, child number 3
67 SQL_ID 5sx5b8gvbkp29, child number 4
74 SQL_ID 5sx5b8gvbkp29, child number 5
81 SQL_ID 5sx5b8gvbkp29, child number 6
90 SQL_ID 5sx5b8gvbkp29, child number 7
99 SQL_ID 5sx5b8gvbkp29, child number 8
108 SQL_ID 5sx5b8gvbkp29, child number 9
119 SQL_ID 5sx5b8gvbkp29, child number 10
131 SQL_ID 5sx5b8gvbkp29, child number 11
144 SQL_ID 5sx5b8gvbkp29, child number 12
159 SQL_ID 5sx5b8gvbkp29, child number 13
175 SQL_ID 5sx5b8gvbkp29, child number 14
192 SQL_ID 5sx5b8gvbkp29, child number 15
211 SQL_ID 5sx5b8gvbkp29, child number 16
232 SQL_ID 5sx5b8gvbkp29, child number 17
256 SQL_ID 5sx5b8gvbkp29, child number 18
281 SQL_ID 5sx5b8gvbkp29, child number 19
309 SQL_ID 5sx5b8gvbkp29, child number 20
340 SQL_ID 5sx5b8gvbkp29, child number 21
374 SQL_ID 5sx5b8gvbkp29, child number 22
412 SQL_ID 5sx5b8gvbkp29, child number 23
453 SQL_ID 5sx5b8gvbkp29, child number 24
498 SQL_ID 5sx5b8gvbkp29, child number 25
548 SQL_ID 5sx5b8gvbkp29, child number 26
603 SQL_ID 5sx5b8gvbkp29, child number 27
663 SQL_ID 5sx5b8gvbkp29, child number 28
729 SQL_ID 5sx5b8gvbkp29, child number 29
802 SQL_ID 5sx5b8gvbkp29, child number 30
882 SQL_ID 5sx5b8gvbkp29, child number 31
971 SQL_ID 5sx5b8gvbkp29, child number 32
1068 SQL_ID 5sx5b8gvbkp29, child number 0
1174 SQL_ID 5sx5b8gvbkp29, child number 1
1292 SQL_ID 5sx5b8gvbkp29, child number 2
1421 SQL_ID 5sx5b8gvbkp29, child number 3
1563 SQL_ID 5sx5b8gvbkp29, child number 33
1719 SQL_ID 5sx5b8gvbkp29, child number 4
1092 SQL_ID 5sx5b8gvbkp29, child number 5
--//與前面測試不同.不過可以確定是使用id2<=:x 中帶入變數有關.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2156139/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle遊標共享,父遊標和子游標的概念Oracle
- [20221101]如何減少BIND_EQUIV_FAILURE引起的子游標.txtUIAI
- [20200129]子游標不共享BIND_EQUIV_FAILURE.txtUIAI
- Oracle - 共享遊標、父子游標、硬軟解析Oracle
- secureCRT游標不見啦Securecrt
- 【CURSOR】Oracle 子游標無法共享的原因之V$SQL_SHARED_CURSOROracleSQL
- [20220328]查詢游標為什麼不共享指令碼.txt指令碼
- [20170904]11Gr2 查詢游標為什麼不共享指令碼指令碼
- 深入理解父遊標,子游標的概念
- oracle實驗記錄 (子游標與解析)Oracle
- 父遊標 子游標和軟硬解析記載-02
- [20220420]完善查詢游標為什麼不共享指令碼.txt指令碼
- v$sql v$sqlarea和父遊標 子游標記載01SQL
- [20160407]游標共享TOP_LEVEL_RPI_CURSOR
- PLSQL Language Referenc-PL/SQL靜態SQL-游標變數-游標變數作為子程式引數SQL變數
- input 獲取游標位置與設定游標位置
- 子游標過多導致大量mutex爭用故障分析Mutex
- v$sql v$sqlarea v$sql_shared_cursor及父遊標,子游標SQL
- win10筆記本滑鼠游標不見了怎麼辦 win10滑鼠游標恢復的方法Win10筆記
- 游標操作快捷鍵
- winform之手繪矩形及游標字串與游標關聯顯示ORM字串
- (12)mysql 中的游標MySql
- 阻止游標預設事件事件
- css 滑鼠游標設定CSS
- win10游標怎麼縮放_win10游標縮放方法Win10
- 【CSS: cursor】滑鼠游標指標樣式大全CSS指標
- 設定/獲得游標位置
- Mac滑鼠游標消失怎麼辦?蘋果電腦滑鼠指標不顯示的解決方法Mac蘋果指標
- cad游標大小怎麼調 cad游標中心正方形大小設定
- win10如何換滑鼠游標 win10更換滑鼠游標怎麼操作Win10
- PLSQL Language Referenc-PL/SQL靜態SQL-游標變數-建立游標變數SQL變數
- el-input 限制number型別,輸入中文,游標不垂直居中問題型別
- 1224關於共享池4SQL記憶體結構父子游標補充SQL記憶體
- win10 更改游標顏色方法 win10 滑鼠游標顏色怎麼改Win10
- PLSQL Language Referenc-PL/SQL靜態SQL-游標變數-游標變數賦值SQL變數賦值
- Web 中的“選區”和“游標”Web
- UITextField 游標位置,placeholder樣式UI
- (012)mysql中的游標MySql