[20200129]子光标不共享BIND_EQUIV_FAILURE.txt

--//生产系统再次遇到大量BIND_EQUIV_FAILURE原因导致子光标的情况。我看了我以前测试遇到的情况。
--//链接 http://blog.itpub.net/267265/viewspace-2156139/ =>[20180613]子光标不共享BIND_EQUIV_FAILURE。
--//别人曾经给我建议,问题可能出在alter session set statistics_level=all;的设置上,我也重复测试看看。

1.环境:
SCOTT@test01p> @ ver1
PORT_STRING          VERSION    BANNER                                                                       CON_ID
-------------------- ---------- ---------------------------------------------------------------------------- ------
IBMPC/WIN_NT64-9.1.0 12.2.0.1.0 Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production      0

SYS@test> @ hide _cursor_obsolete_threshold
NAME                       DESCRIPTION                                     DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE ISSES ISSYS_MOD
-------------------------- ----------------------------------------------- ------------- ------------- ------------ ----- ---------
_cursor_obsolete_threshold Number of cursors per parent before obsoletion. TRUE          8192          8192         TRUE  FALSE

/*
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,1000)+1 id2 from dual connect by level<=2000;

SCOTT@test01p> select * from dba_extents where owner=user and segment_name='T'
  2  @ prxx
==============================
OWNER                         : SCOTT
SEGMENT_NAME                  : T
PARTITION_NAME                :
SEGMENT_TYPE                  : TABLE
TABLESPACE_NAME               : USERS
EXTENT_ID                     : 0
FILE_ID                       : 11
BLOCK_ID                      : 176
BYTES                         : 65536
BLOCKS                        : 8
RELATIVE_FNO                  : 11
PL/SQL procedure successfully completed.

2.建立测试脚本:
--//建立脚本by.txt,注解alter session set statistics_level=all;:
set term off
--//alter session set statistics_level=all;
variable x number;
exec :x := &&1;
SElect t.* from t where id2<=:x;
set term on
@ dpc '' ''
quit

--//建立shell脚本by.sh:
#!/bin/bash
# rm -f ez.txt
for i in $(seq 1000)
do
    sqlplus -s -l scott/btbtms@test01p @by.txt $i >> ez.txt
done
--//在家里的笔记本上测试有点慢,减少循环到1000次。

3.测试:
--//执行脚本by.sh.
$ grep "SQL_ID" ez.txt |  uniq -c
   1000 SQL_ID  ckynkwp4t00rz, child number 0
--//可以发现并没有产生子光标。确实像别人讲的那样。

4.继续测试:
--//修改脚本by.txt.取消注解alter session set statistics_level=all;.
set term off
alter session set statistics_level=all;
variable x number;
exec :x := &&1;
SElect t.* from t where id2<=:x;
set term on
@ dpc '' ''
quit

--//刷新共享池3次。
alter session set statistics_level=all;
alter session set statistics_level=all;
alter session set statistics_level=all;

$ mv ez.txt ezold.txt

--//执行脚本by.sh

$ grep "SQL_ID" ez.txt |  uniq -c
    500 SQL_ID  ckynkwp4t00rz, child number 0
     51 SQL_ID  ckynkwp4t00rz, child number 1
     56 SQL_ID  ckynkwp4t00rz, child number 2
     61 SQL_ID  ckynkwp4t00rz, child number 3
     67 SQL_ID  ckynkwp4t00rz, child number 4
     74 SQL_ID  ckynkwp4t00rz, child number 5
     81 SQL_ID  ckynkwp4t00rz, child number 6
     90 SQL_ID  ckynkwp4t00rz, child number 7
     20 SQL_ID  ckynkwp4t00rz, child number 8
--//在执行过程中,可以发现并出现大量子光标.

SCOTT@test01p> @ share ckynkwp4t00rz
old  15:           and q.sql_id like ''&1''',
new  15:           and q.sql_id like ''ckynkwp4t00rz''',
SQL_TEXT                       = SElect t.* from t where id2<=:x
SQL_ID                         = ckynkwp4t00rz
ADDRESS                        = 000007FF12B9AA10
CHILD_ADDRESS                  = 000007FF1265EDE8
CHILD_NUMBER                   = 0
LOAD_OPTIMIZER_STATS           = Y
REASON                         = <ChildNode><ChildNumber>0</ChildNumber><ID>39</ID><reason>Bind mismatch(25)</reason><size>0x0</size><details>extended_cursor_sharing</details></ChildNode>
--------------------------------------------------
SQL_TEXT                       = SElect t.* from t where id2<=:x
SQL_ID                         = ckynkwp4t00rz
ADDRESS                        = 000007FF12B9AA10
CHILD_ADDRESS                  = 000007FF16F0F400
CHILD_NUMBER                   = 1
REASON                         = <ChildNode><ChildNumber>1</ChildNumber><ID>39</ID><reason>Bind mismatch(33)</reason><size>1x4</size><init_ranges_in_first_pass>2540213050</init_ranges_in_first_pass></ChildNode>
--------------------------------------------------
SQL_TEXT                       = SElect t.* from t where id2<=:x
SQL_ID                         = ckynkwp4t00rz
ADDRESS                        = 000007FF12B9AA10
CHILD_ADDRESS                  = 000007FF13C989F8
CHILD_NUMBER                   = 2
BIND_EQUIV_FAILURE             = Y
REASON                         = <ChildNode><ChildNumber>2</ChildNumber><ID>39</ID><reason>Bind mismatch(33)</reason><size>1x4</size><init_ranges_in_first_pass>2841161709</init_ranges_in_first_pass></ChildNode>
--------------------------------------------------
...
--------------------------------------------------
SQL_TEXT                       = SElect t.* from t where id2<=:x
SQL_ID                         = ckynkwp4t00rz
ADDRESS                        = 000007FF12B9AA10
CHILD_ADDRESS                  = 000007FF13F41A10
CHILD_NUMBER                   = 8
BIND_EQUIV_FAILURE             = Y
REASON                         =
--------------------------------------------------
PL/SQL procedure successfully completed.

$ grep "SQL_ID" ez.txt |  uniq -c | awk '{ sum=sum+$1};END {print sum}'
1000
--//正好1000次。
--//可以看出设置alter session set statistics_level=all;导致出现子光标不能共享,具体原因是什么不清楚。
--//我反复测试多次,结果都是一样。

5.建立直方图呢?

SCOTT@test01p> execute sys.dbms_stats.gather_table_stats ( OwnName => user,TabName => 't',Estimate_Percent => NULL,Method_Opt => 'FOR ALL COLUMNS SIZE 1024 ',Cascade => True ,No_Invalidate => false)
PL/SQL procedure successfully completed.
--//12c 可以支持bucket大于254.

SCOTT@test01p> @ tab_lh scott t ''

DISPLAY TABLE_NAME OF COLUMN_NAME INFORMATION.
INPUT   OWNER TABLE_NAME COLUMN
SAMPLE  : @ TAB_LH TABLE_NAME [COLUMN_NAME]
IF NOT INPUT COLUMN_NAME ,USE "" .

COLUMN_NAME DATA_TYPE DATA_LENGTH N NUM_DISTINCT    DENSITY SAMPLE_SIZE TRANS_LOW TRANS_HIGH  NUM_NULLS NUM_BUCKETS LAST_ANALYZED       HISTOGRAM  DATA_DEFAULT
----------- --------- ----------- - ------------ ---------- ----------- --------- ---------- ---------- ----------- ------------------- ---------- -------------------------
ID1         NUMBER             22 Y         2000      .0005        2000 1         2000                0        1024 2020-01-29 19:44:04 HYBRID
ID2         NUMBER             22 Y         1000     .00025        2000 1         1000                0        1000 2020-01-29 19:44:04 FREQUENCY

--//刷新共享池3次。
alter session set statistics_level=all;
alter session set statistics_level=all;
alter session set statistics_level=all;

--//执行脚本by.txt。
set term off
--//alter session set statistics_level=all;
variable x number;
exec :x := &&1;
SElect t.* from t where id2<=:x;
set term on
@ dpc '' ''
quit

$ mv ez.txt ez17.txt
$ grep "SQL_ID" ez.txt |  uniq -c
   1000 SQL_ID  ckynkwp4t00rz, child number 0
--//没有子光标产生。

SCOTT@test01p> execute sys.dbms_stats.gather_table_stats ( OwnName => user,TabName => 't',Estimate_Percent => NULL,Method_Opt => 'FOR ALL COLUMNS SIZE 254 ',Cascade => True ,No_Invalidate => false)
PL/SQL procedure successfully completed.

SCOTT@test01p> @ tab_lh scott t ''

DISPLAY TABLE_NAME OF COLUMN_NAME INFORMATION.
INPUT   OWNER TABLE_NAME COLUMN
SAMPLE  : @ TAB_LH TABLE_NAME [COLUMN_NAME]
IF NOT INPUT COLUMN_NAME ,USE "" .
COLUMN_NAME DATA_TYPE DATA_LENGTH N NUM_DISTINCT    DENSITY SAMPLE_SIZE TRANS_LOW TRANS_HIGH NUM_NULLS NUM_BUCKETS LAST_ANALYZED       HISTOGRAM DATA_DEFAULT
----------- --------- ----------- - ------------ ---------- ----------- --------- ---------- --------- ----------- ------------------- --------- ------------
ID1         NUMBER             22 Y         2000      .0005        2000 1         2000               0         254 2020-01-29 20:01:43 HYBRID
ID2         NUMBER             22 Y         1000       .001        2000 1         1000               0         254 2020-01-29 20:01:43 HYBRID

--//刷新共享池3次。
alter session set statistics_level=all;
alter session set statistics_level=all;
alter session set statistics_level=all;

$ mv ez.txt ez18.txt

$ grep "SQL_ID" ez.txt |  uniq -c
   1000 SQL_ID  ckynkwp4t00rz, child number 0
--//没有子光标产生。
--//也就是与直方图无关。

6.继续测试:
--//取消直方图设置。
SCOTT@test01p> execute sys.dbms_stats.gather_table_stats ( OwnName => user,TabName => 't',Estimate_Percent => NULL,Method_Opt => 'FOR ALL COLUMNS SIZE 1 ',Cascade => True ,No_Invalidate => false)
PL/SQL procedure successfully completed.

$ cat by.txt
set term off
alter session set statistics_level=all;
variable x number;
exec :x := &&1;
SElect t.* from t where id1<=:x;
set term on
@ dpc '' ''
quit

$ cat by.sh
#!/bin/bash
# rm -f ez.txt
for i in $(seq 2000 )
do
   sqlplus -s -l scott/btbtms@test01p @by.txt $i >> ez.txt
done

alter system flush shared_pool;

--//注意查新条件是id1<= :x,验证在x=1000后是否出现子光标。

SCOTT@test01p> @ share basmuva6swhg4
SQL_TEXT                       = SElect t.* from t where id1<=:x
SQL_ID                         = basmuva6swhg4
ADDRESS                        = 000007FF1314E908
CHILD_ADDRESS                  = 000007FF13133298
CHILD_NUMBER                   = 0
LOAD_OPTIMIZER_STATS           = Y
REASON                         = <ChildNode><ChildNumber>0</ChildNumber><ID>39</ID><reason>Bind mismatch(25)</reason><size>0x0</size><details>extended_cursor_sharing</details></ChildNode>
--------------------------------------------------
SQL_TEXT                       = SElect t.* from t where id1<=:x
SQL_ID                         = basmuva6swhg4
ADDRESS                        = 000007FF1314E908
CHILD_ADDRESS                  = 000007FF13270B40
CHILD_NUMBER                   = 1
REASON                         = <ChildNode><ChildNumber>1</ChildNumber><ID>39</ID><reason>Bind mismatch(33)</reason><size>1x4</size><init_ranges_in_first_pass>3229815407</init_ranges_in_first_pass></ChildNode>
--------------------------------------------------
SQL_TEXT                       = SElect t.* from t where id1<=:x
SQL_ID                         = basmuva6swhg4
ADDRESS                        = 000007FF1314E908
CHILD_ADDRESS                  = 000007FF1343C4A0
CHILD_NUMBER                   = 2
BIND_EQUIV_FAILURE             = Y
REASON                         = <ChildNode><ChildNumber>2</ChildNumber><ID>39</ID><reason>Bind mismatch(33)</reason><size>1x4</size><init_ranges_in_first_pass>2954937500</init_ranges_in_first_pass></ChildNode>
..
PL/SQL procedure successfully completed.

$ grep "SQL_ID" ez.txt |  uniq -c
   1000 SQL_ID  basmuva6swhg4, child number 0
    101 SQL_ID  basmuva6swhg4, child number 1
    111 SQL_ID  basmuva6swhg4, child number 2
    122 SQL_ID  basmuva6swhg4, child number 3
    134 SQL_ID  basmuva6swhg4, child number 4
    147 SQL_ID  basmuva6swhg4, child number 5
    162 SQL_ID  basmuva6swhg4, child number 6
    178 SQL_ID  basmuva6swhg4, child number 7
     45 SQL_ID  basmuva6swhg4, child number 8

$ grep "SQL_ID" ez.txt |  uniq -c | awk 'BEGIN {a=909;} {sum=sum+$1;a=a*1.10;print  sum, a }'
1000 999.9
1101 1099.89
1212 1209.88
1334 1330.87
1468 1463.95
1615 1610.35
1777 1771.38
1955 1948.52
2000 2143.37

--//可以看出一个规律返回1000条记录是第1道坎,以后大约按照0.11的比例增加(最后一行测试不足不算)。当然这仅仅是我的猜测。

7.继续测试:
--//翻转执行看看,先执行2000:
$ cat by.sh
#!/bin/bash
# rm -f ez.txt
for i in $(seq 2000 -1 1 )
do
        sqlplus -s -l scott/btbtms@test01p @by.txt $i >> ez.txt
done

$ grep "SQL_ID" ez.txt |  uniq -c
   2000 SQL_ID  basmuva6swhg4, child number 0

--//并没有产生子光标。

[20200129]子光标不共享BIND_EQUIV_FAILURE.txt的更多相关文章

  1. [20170904]11Gr2 查询光标为什么不共享脚本.txt

    [20170904]11Gr2 查询光标为什么不共享脚本.txt --//参考链接下面的注解脚本:https://carlos-sierra.net/2017/09/01/poors-man-scri ...

  2. [20190415]10g下那些latch是共享的.txt

    [20190415]10g下那些latch是共享的.txt http://andreynikolaev.wordpress.com/2010/11/23/shared-latches-by-oracl ...

  3. [20190415]11g下那些latch是共享的.txt

    [20190415]11g下那些latch是共享的.txt http://andreynikolaev.wordpress.com/2010/11/23/shared-latches-by-oracl ...

  4. TP、PHP同域不同子级域名共享Session、单点登录

    TP.PHP同域不同子级域名共享Session.单点登录 目的: 为了部署同个域名下不同子级域名共享会话,从而实现单点登录的问题,一处登录,同域处处子系统即可以实现自动登录. PHP支持通过设置coo ...

  5. Tkinter 吐槽之二:Event 事件在子元素中共享

    背景 最近想简单粗暴的用 Python 写一个 GUI 的小程序.因为 Tkinter 是 Python 自带的 GUI 解决方案,为了部署方便,就直接选择了 Tkinter. 本来觉得 GUI 发展 ...

  6. [20190319]shared pool latch与library cache latch的简单探究.txt

    [20190319]shared pool latch与library cache latch的简单探究.txt --//昨天看Oracle DBA手记3:数据库性能优化与内部原理解析.pdf 电子书 ...

  7. [20180819]关于父子游标问题(11g).txt

    [20180819]关于父子游标问题(11g).txt --//sql语句存在父子游标,子游标堆6在父游标堆0里面.--//如果存在许多子游标的情况下,父游标堆0是否大小是发生变化呢.测试看看.--/ ...

  8. [20180625]oradebug peek 2.txt

    [20180625]oradebug peek 2.txt --//上个星期演示了oradebug peek查看内存数据块的情况,oradebug peek {address} length 1,最后 ...

  9. [20181229]关于字符串的分配问题.txt

    [20181229]关于字符串的分配问题.txt --//链接:http://www.itpub.net/thread-2107534-1-1.html提到的问题,里面一段英文读起来很绕口:--//百 ...

随机推荐

  1. 实验一:通过Access划分vlan

    1.配置图 Switch0的fa0/1.fa0/2.fa0/3端口设置为Access模式,PC1和PC2属于vlan 2,PC3属于vlan 3. 2.Switch0配置 3.实验现象 PC1可以pi ...

  2. 聊一聊 InnoDB 引擎中的这些索引策略

    在上一篇中,我们简单的介绍了一下 InnoDB 引擎的索引类型,这一篇我们继续学习 InnoDB 的索引,聊一聊索引策略,更好的利用好索引,提升数据库的性能,主要聊一聊覆盖索引.最左前缀原则.索引下推 ...

  3. Mayor's posters (线段树+离散化)

    Mayor's posters Description The citizens of Bytetown, AB, could not stand that the candidates in the ...

  4. ajax--->请求异常 jQuery提示parsererror错误解决办法

    ajax请求异常 jQuery提示parsererror错误解决办法 原因:出现这个错误是因为后端返回的数据类型和前端请求中dataType的要求类型不一致导致的. dataType简介:jquery ...

  5. SpringCloud与微服务Ⅱ --- 微服务概述

    一.什么是微服务 1) Martin Fowler论文对微服务的阐述(中文版) 2) 对单一应用进行拆分 3) 每一个独立的应用都有一个独立的进程 4) 拥有自己独立的数据库 5) 微服务化的核心就是 ...

  6. Intent传递实现Parcelable接口的对象

    Intent可以传递基本数据类型,在对象实现了Parcelable接口后,Intent也可以传递对象. 1. 使类ListVideo实现了Parcelable接口. package com.examp ...

  7. Arduino系列之中断函数

    今天我将简单记录中断函数 函数分为外部中断和定时中断 外部中断的定义:一般由外设发出中断请求,如:键盘中断.打印机中断.外部中断需外部中断源发出中断请求才能发中断. 定时中断的定义:是指主程序在运行一 ...

  8. OpenCV3入门(二)Mat操作

    1.Mat结构 1.1.Mat数据 Mat本质上是由两个数据部分组成的类: 矩阵头:包含信息有矩阵的大小,用于存储的方法,矩阵存储的地址等 数据矩阵指针:指向包含了像素值的矩阵. 矩阵头部的大小是恒定 ...

  9. kvm 中 Guest Is already in use 处理办法

    在安装kvm时,如果安装相同名字的虚拟机,是会有错误提示的,就算是删除了虚拟机的xml文件,也会弹出错误提示.如下: ERROR Guest name 'test' is already in use ...

  10. partition show for oracle version

    Dear all You may remember that my blog has a view script for checking sqlserver partition tables. No ...