recursive calls

来源:互联网 发布:剑灵灵族正太捏脸数据 编辑:程序博客网 时间:2024/05/16 17:13

本文转自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。

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

     现在让我们举例说明:

[sql] view plaincopyprint?
  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] view plaincopyprint?
  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.    


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

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


 

原创粉丝点击