[20160407]光标共享TOP_LEVEL_RPI_CURSOR

[20160407]光标共享问题TOP_LEVEL_RPI_CURSOR.txt

--以前做测试出现,光标不能共享TOP_LEVEL_RPI_CURSOR,不知道什么意思,链接:
-- http://blog.itpub.net/267265/viewspace-765072/

--今天看blog,终于明白表示什么意思?参考链接:
-- http://www.peasland.net/2016/04/05/vsql_shared_cursor-top_level_rpi_cursor/

--为了加强记忆,我重复我原来的测试:

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

$ cat soft_parse.sql
--connect scott/book
begin
for i in 1..10 loop
    execute immediate 'select 1234567890 from dual';
end loop;
end;
/

--单独执行:
select 1234567890 from dual;

2.开始测试:

SCOTT@book> @ soft_parse.sql
PL/SQL procedure successfully completed.

SCOTT@book> select 1234567890 from dual;
1234567890
----------
1234567890

SCOTT@book> @ &r/share 0ta1datg212yk
SQL_TEXT                       = select 1234567890 from dual
SQL_ID                         = 0ta1datg212yk
ADDRESS                        = 000000007C4EF010
CHILD_ADDRESS                  = 000000007C6AFBD0
CHILD_NUMBER                   = 0
REASON                         = <ChildNode><ChildNumber>0</ChildNumber><ID>7</ID><reason>Top Level RPI Cursor(0)</reason><size>2x4</size><ctxxyfl>1024</ctxxyfl><ispri>0</ispri></ChildNode>
--------------------------------------------------
SQL_TEXT                       = select 1234567890 from dual
SQL_ID                         = 0ta1datg212yk
ADDRESS                        = 000000007C4EF010
CHILD_ADDRESS                  = 000000007BB942A8
CHILD_NUMBER                   = 1
TOP_LEVEL_RPI_CURSOR           = Y
REASON                         =
--------------------------------------------------
PL/SQL procedure successfully completed.

--以前真不明白为什么不能共享光标.

SCOTT@book> select child_number,sql_id,executions from v$sql where sql_id='0ta1datg212yk';
CHILD_NUMBER SQL_ID        EXECUTIONS
------------ ------------- ----------
           0 0ta1datg212yk         10
           1 0ta1datg212yk          1

--我转抄作者的blog:http://www.peasland.net/2016/04/05/vsql_shared_cursor-top_level_rpi_cursor/

So what does it mean when TOP_LEVEL_RPI_CURSOR is set to Y for a child? The documentation isn't clear. MOS has very
little on the subject. And all of my Google hits on this column pretty much just regurgitate the documentation. To know
why, it helps to know that RPI stands for Recursive Program Interface. This is part of the Oracle kernel that deals with
recursive SQL. In our case, it deals with the fact that the SQL statement was issued at a different "depth".

What is recursive SQL? It is SQL that is issued on your behalf, which means at a different depth as I will illustrate.
First off, Oracle is performing recursive SQL all the time. At a basic level, when you issue "select * from table_name",
Oracle queries the Data Dictionary to ensure the object exists and that you have permissions on that table. How does
Oracle do that? It uses other SQL statements. The statement you issue is at level 0, the base level. When Oracle issues
a SQL statement to check if the table exists, that will be at the next level, level 1. Sometimes, that will cause other
SQL statements to be issued at the next level, level 2.

The depth of a SQL statement is not limited to just what Oracle is doing in the background, on your behalf. Consider
when you execute a stored procedure. Your call to the stored procedure is at depth 0. Any SQL statement in the stored
procedure is at depth 1. If that stored procedure calls another procedure, the SQL in the other procedure will be at
depth 2.

3. 做一个10046跟踪就很容易明白:
SCOTT@book> @ &r/10046on 12
Session altered.

SCOTT@book> select 1234567890 from dual;
1234567890
----------
1234567890

SCOTT@book> @ soft_parse.sql
PL/SQL procedure successfully completed.

SCOTT@book> @ &r/10046off
Session altered.

$ grep 0ta1datg212yk /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_44465.trc
PARSING IN CURSOR #139973607848760 len=27 dep=0 uid=83 oct=3 lid=83 tim=1459994779203747 hv=1579191250 ad='7c4ef010' sqlid='0ta1datg212yk'
PARSING IN CURSOR #139973610685288 len=27 dep=1 uid=83 oct=3 lid=83 tim=1459994782403968 hv=1579191250 ad='7c4ef010' sqlid='0ta1datg212yk'

--注意看dep不一样.注意我的执行顺序,我是先执行select 1234567890 from dual;,再调用soft_parse.sq.
--前者dep=0,后者dep=1.

时间: 2024-07-30 10:53:34

[20160407]光标共享TOP_LEVEL_RPI_CURSOR的相关文章

[20171019]关于光标共享问题.txt

[20171019]关于光标共享问题.txt --//如果sql语句光标不能共享,查看v$sql_shared_cursor视图. --//别人问的问题,如果存在两个因素是否显示2个原因.自己还是测试看看. 1.环境: SCOTT@test01p> @ver1 PORT_STRING                    VERSION        BANNER                                                                   

[20170621]Session Cursor Caching 2.txt

[20170621]Session Cursor Caching 2.txt --//当sql执行时,第一次要经历硬分析,第二次软分析,如果session_cached_cursors设置的化,还可以绕过软分析,也有人叫"软软分析". --//摘录链接的一段话: --//www.toadworld.com/platforms/oracle/b/weblog/archive/2017/04/12/session-cursor-caching-part-one When a SQL sta

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

[20170904]11Gr2 查询光标为什么不共享脚本.txt --//参考链接下面的注解脚本: https://carlos-sierra.net/2017/09/01/poors-man-script-to-summarize-reasons-why-cursors-are-not-shared/ --//做一个记录. SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ---------

[20160516]SQL共享光标的测试疑问.txt

[20160516]SQL共享光标的测试疑问.txt --昨天我看了链接http://blog.itpub.net/17203031/viewspace-754994/,感觉他的测试有问题,不可能相同的sql语句,而sql_id会不一样 --的.我自己测试看看. 1.环境: SYS@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ------------------------------ ------

[20160713]为什么光标不能共享.txt

[20160713]为什么光标不能共享.txt --这个是生产系统遇到的问题,有1条语句产生的子光标很多,但是直接查询v$sql仅仅有1个(CHILD_NUMBER很大). --检查为什么不能共享的原因是ROLL_INVALID_MISMATCH. ROLL_INVALID_MISMATCH reason indicates that, after a fresh statistics, using dbms_stats.auto_invalidate value for the paramet

WiFi共享大师怎么设置密码

  现在WiFi越来越普遍了,所以很多朋友都喜欢使用WiFi共享大师来分享WiFi,那么WiFi共享大师怎么设置密码.WiFi共享大师怎么限速,本文就来说说这个问题. 使用wifi共享大师时,很多朋友觉得wifi共享大师默认的密码太简单,为了不让别人蹭网,想要修改wifi密码,却不知道怎么修改,小编首先教教大家如何修改wifi共享大师的密码. wifi共享大师怎么设置密码,wifi共享大师怎么修改密码: wifi共享大师修改密码的方法很简单,在wifi共享大师运行界面,wifi名称后面有个像圆珠

wifi共享大师怎么限速拉黑

  wifi共享大师怎么限速拉黑?小编用过不少WiFi共享Software,发现wifi共享大师界面比较简洁,而且还能设置自动关机实现手机控制,还是很不错的.使用软件的过程中,万一还有人蹭网拖慢网速怎么办?这个时候就直接把他拉黑好了.那么wifi共享大年夜师怎么限速拉黑呢,这个功能怎么使用呢?今天,安下小编带给大家wifi共享大师限速拉黑方法,具体操作大家请参考下文吧. wifi共享大师限速拉黑方法 首先,打开软件. 鼠标光标放在要处理的设备上. 如图所示标志便是拉黑,点击. 在弹出方框里选择确

主机为windows7客户机为windowsxp如何实现共享打印机

一.主机Windows7系统设置   1.先安装WIN7的打印机驱动程序.关闭系统防火墙. 关闭系统防火墙:进入电脑[控制面板]→[WINDOWS防火墙]→[打开或关闭WINDOWS防火墙]→[关闭防火墙].     2.点击电脑左下角[开始]→[设备和打印机]-找到打印机图标.   3.右键单击打印机图标,选择[打印机属性]→[共享]→[共享这台打印机]和[在客户端计算机上呈现打印作业]都画钩,然后再按[确定].   图1:     图2:     二.客户机Windows XP系统设置  

怎样实时监控鼠标在屏幕上的光标变化(用于监控软件)

问题描述 传统监控软件只是将桌面截图,然后传送过去,并不能实时监控光标的实时变化.现要求实时看到鼠标的变化.不知怎样实现,大家一起讨论.小弟:用共享dll+hook钩子实现,将鼠标实时画的截取的桌面图片上.由于本人编程水平有限!还望大家指点一下 解决方案 解决方案二:g_hHook=SetWindowsHookEx(WH_MOUSE,MouseProc,_Module.m_hInst,GetCurrentThreadId());//安装HOOKLRESULTCALLBACKMouseProc(i