recursive calls

本文转自http://blog.csdn.net/rulev5/article/details/6988180

 

 

 

recursive calls重点讲解

官网对recursive calls 的解释如下:


       Recursive Calls:  Number of recursive calls generated at both the user and system level.    


       Oracle Database maintains tables used for internal processing. When it needs to change these tables, Oracle Database generates an internal SQL statement, which in turn generates a recursive call.In short, recursive calls are basically SQL performed on behalf of your SQL. So, if you had to parse the query, for example, you might have had to run some other queries to get data dictionary information. These would be recursive calls. Space management, security checks, calling PL/SQL from SQL—all incur recursive SQL calls。

       IBM上面也有一篇讲解,有兴趣可以看看

       http://publib.boulder.ibm.com/tividd/td/ITMD/SC23-4724-00/en_US/HTML/oraclepac510rg59.htm

       总结一下:

       当执行一条SQL语句时,产生的对其他SQL语句的调用,这些额外的语句称之为''recursive calls''或''recursive SQL statements''.

       在IBM 的那片文档里讲了触发Recursive Call的6种情况:  

       如:

       (1)我们做一条insert 时,没有足够的空间来保存row记录,Oracle 通过Recursive Call 来动态的分配空间。

       (2)执行DDL语句时,ORACLE总是隐含的发出一些recursive SQL语句,来修改数据字典信息,以便成功的执行该DDL语句。

       (3)当Shared Pool过小,data dictionary cache 也会相应的过小,没有足够的空间存储ORACLE的系统数据字典信息时,会发生Recursive calls,这些Recursive calls会将数据字典信息从硬盘读入内存中。

       (4)存储过程、触发器内如果有SQL调用的话,也会产生recursive SQL。

       在这些情况中,主要是对数据字典的查询,通常发生在第一次执行时,第二次执行一般可显著降低。递归需要消耗大量的资源,如果操作复杂,很容易出现问题!

     现在让我们举例说明:

  1. SQL> select * from employees;  
  2.   
  3. 107 rows selected.  
  4.   
  5.   
  6. Execution Plan  
  7. ----------------------------------------------------------   
  8. Plan hash value: 1445457117  
  9.   
  10. -------------------------------------------------------------------------------   
  11. | Id  | Operation         | Name      | Rows  | Bytes | Cost (%CPU)| Time     |  
  12. -------------------------------------------------------------------------------   
  13. |   0 | SELECT STATEMENT  |           |   107 |  7276 |     3   (0)| 00:00:01 |  
  14. |   1 |  TABLE ACCESS FULL| EMPLOYEES |   107 |  7276 |     3   (0)| 00:00:01 |  
  15. -------------------------------------------------------------------------------   
  16.   
  17.   
  18. Statistics  
  19. ----------------------------------------------------------   
  20.           1  recursive calls  
  21.           0  db block gets  
  22.          15  consistent gets  
  23.           0  physical reads  
  24.           0  redo size  
  25.        9997  bytes sent via SQL*Net to client  
  26.         569  bytes received via SQL*Net from client  
  27.           9  SQL*Net roundtrips to/from client  
  28.           0  sorts (memory)  
  29.           0  sorts (disk)  
  30.         107  rows processed  
  31.    
SQL> select * from employees;

107 rows selected.


Execution Plan
----------------------------------------------------------
Plan hash value: 1445457117

-------------------------------------------------------------------------------
| Id  | Operation         | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |           |   107 |  7276 |     3   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| EMPLOYEES |   107 |  7276 |     3   (0)| 00:00:01 |
-------------------------------------------------------------------------------


Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
         15  consistent gets
          0  physical reads
          0  redo size
       9997  bytes sent via SQL*Net to client
        569  bytes received via SQL*Net from client
          9  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
        107  rows processed
 


让我们再执行一遍

  1. SQL> select * from employees;  
  2.   
  3. 107 rows selected.  
  4.   
  5.   
  6. Execution Plan  
  7. ----------------------------------------------------------   
  8. Plan hash value: 1445457117  
  9.   
  10. -------------------------------------------------------------------------------   
  11. | Id  | Operation         | Name      | Rows  | Bytes | Cost (%CPU)| Time     |  
  12. -------------------------------------------------------------------------------   
  13. |   0 | SELECT STATEMENT  |           |   107 |  7276 |     3   (0)| 00:00:01 |  
  14. |   1 |  TABLE ACCESS FULL| EMPLOYEES |   107 |  7276 |     3   (0)| 00:00:01 |  
  15. -------------------------------------------------------------------------------   
  16.   
  17.   
  18. Statistics  
  19. ----------------------------------------------------------   
  20.           0  recursive calls  
  21.           0  db block gets  
  22.          15  consistent gets  
  23.           0  physical reads  
  24.           0  redo size  
  25.        9997  bytes sent via SQL*Net to client  
  26.         569  bytes received via SQL*Net from client  
  27.           9  SQL*Net roundtrips to/from client  
  28.           0  sorts (memory)  
  29.           0  sorts (disk)  
  30.         107  rows processed  
  31.    
SQL> select * from employees;

107 rows selected.


Execution Plan
----------------------------------------------------------
Plan hash value: 1445457117

-------------------------------------------------------------------------------
| Id  | Operation         | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |           |   107 |  7276 |     3   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| EMPLOYEES |   107 |  7276 |     3   (0)| 00:00:01 |
-------------------------------------------------------------------------------


Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
         15  consistent gets
          0  physical reads
          0  redo size
       9997  bytes sent via SQL*Net to client
        569  bytes received via SQL*Net from client
          9  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
        107  rows processed
 


在第一次查询employees时,产生了1次recursive Call,第二次查询的时候,因为数据字典的信息信息已经放在cache里,所以第二次的recursive call 为0. 如果第二次也没有完全cache,那么也是会产生recursive call,但次数比第一次少。

其他的从字面上面就可以看出来了,不需要多解释了吧。


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值