Oracle执行分析详细(四)

2014-11-24 16:18:24 · 作者: · 浏览: 9
LOYEE_ID"=205) Statistics ---------------------------------------------------------- 0 recursive calls 0 db block gets 4 consistent gets 0 physical reads 0 redo size 749 bytes sent via SQL*Net to client 492 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed

5、Byte

扫描的数据的字节数

6、Cost

这里上次讲过了,这里简单说下吧。

cost没有单位,是一个相对值,是sql文以cbo方式解析执行时,供oracle用来评估cbo成本,选择执行计划用的。

公式:Cost=(Single block I/O cost+ Multiblock I/O cost+ CPU cost)/sreadtim

没有明确的含义,不过对比时就非常有用了。

7、Time

每段执行的时间

二、Predicate Information

这里列出的是过滤条件,一共有两种:

1、索引(access)

如上例中的access("B"."EMPLOYEE_ID"=205),这里使用索引作为过滤条件

2、非索引(filter),看下面这里例子

[sql] view plaincopyprint
  1. SQL> select employee_id from employees c
  2. where c.first_name = 'Steven' 2 3 ;
  3. Execution Plan
  4. ---------------------------------------------------------- Plan hash value: 1445457117
  5. -------------------------------------------------------------------------------
  6. | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------------
  7. | 0 | SELECT STATEMENT | | 1 | 11 | 3 (0)| 00:00:01 | |* 1 | TABLE ACCESS FULL| EMPLOYEES | 1 | 11 | 3 (0)| 00:00:01 |
  8. -------------------------------------------------------------------------------
  9. Predicate Information (identified by operation id): ---------------------------------------------------
  10. 1 - filter("C"."FIRST_NAME"='Steven')
  11. Statistics ----------------------------------------------------------
  12. 1 recursive calls 0 db block gets
  13. 8 consistent gets 0 physical reads
  14. 0 redo size 574 bytes sent via SQL*Net to client
  15. 492 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client
  16. 0 sorts (memory) 0 sorts (disk)
  17. 2 rows processed
    SQL> select employee_id
                      from employees c
                     where c.first_name = 'Steven'   2    3  ;
    
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 1445457117
    
    -------------------------------------------------------------------------------
    | Id  | Operation         | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    -------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |           |     1 |    11 |     3   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| EMPLOYEES |     1 |    11 |     3   (0)| 00:00:01 |
    -------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter("C"."FIRST_NAME"='Steven')
    
    
    Statistics
    ----------------------------------------------------------
              1  recursive calls
              0  db block gets
              8  consistent gets
              0  physical reads
              0  redo size
            574  bytes sent via SQL*Net to client
            492  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              2  rows processed
    

    这里的过滤条件是FIRST_NAME,但是FIRST_NAME没有建立索引,这个时候使用filter,做标记。

    三、Statistics(统计信息)

    这里是重点要说的,如果看累了,可以去喝口水。O(∩_∩)O~

    AUTOTRACE Statistics列解释

    序号

    列名

    解释

    1

    recursive calls

    递归调查

    2

    db block gets

    从buffer cache中读取的block的数量

    3

    consistent gets

    从buffer cache中读取的undo数据的block的数量

    4

    physical reads

    从磁盘读取的block的数量

    5

    redo size

    DML生成的redo的大小

    6

    sorts (memory)

    在内存执行的排序量

    7

    sorts (disk)

    在磁盘上执行的排序量

    1、recursive calls