本文转自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> 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
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
让我们再执行一遍
- 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
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,但次数比第一次少。
其他的从字面上面就可以看出来了,不需要多解释了吧。