码迷,mamicode.com
首页 > 数据库 > 详细

获得执行计划方法-一 ORACLE AUTOTRACE

时间:2014-06-28 06:36:10      阅读:369      评论:0      收藏:0      [点我收藏+]

标签:获得执行计划方法

ORACLE sql trace

    
AUTOTRACE 命令

1 SET AUTOTRACE OFF                   此为默认值,即关闭Autotrace
2 SET AUTOTRACE ON                    产生结果集和解释计划并列出统计
3 SET AUTOTRACE ON EXPLAIN            显示结果集和解释计划不显示统计
4 SETAUTOTRACE TRACEONLY              显示解释计划和统计,尽管执行该语句但您将看不到结果集
5 SET AUTOTRACE  TRACEONLY STATISTICS 只显示统计

SQL> set autotrace on
SQL> select * from dual
  2  ;

D
-
X


Execution Plan
----------------------------------------------------------
Plan hash value: 272002086

--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     1 |     2 |     2   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |
--------------------------------------------------------------------------


Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
          3  consistent gets
          0  physical reads
          0  redo size
        407  bytes sent via SQL*Net to client
        385  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

各统计信息含义
db block gets    从buffer cache中读取的block的数量
consistent gets  从buffer cache中读取的undo数据的block的数量
physical reads   从磁盘读取的block的数量
redo size        DML生成的redo的大小
sorts (memory)   在内存执行的排序量
sorts (disk)     在磁盘上执行的排序量


db block gets 是取得current mode下的buffer cache
consistent gets 取的是consistent  mode 下buffer cache ,其中consistent  read 需要undo block 构造一致读块

官方文档如下

  • Current mode

    A current mode get, also called a db block get, is a retrieval of a block as it currently appears in the buffer cache.

    current mode 也叫 db block get ,是对buffer cache 中当前块的检索。

     For example, if an uncommitted transaction has updated two rows in a block, then a current mode get retrieves the block with these uncommitted rows. 

    例如,如果一个尚未提交的事物修改了一个块的两行,current模式个检索块时,包括两个尚未提交的行

    The database uses db block gets most frequently during modification statements, which must update only the current version of the block.

    数据库通常在使用修改语句时  使用db block get ,哪个必须修改当前块的版本。

  • Consistent mode

    A consistent read get is a retrieval of a read-consistent version of a block. This retrieval may use undo data.

    一致读读取的是块的一致性版本,这通常要使用undo 块。


     For example, if an uncommitted transaction has updated two rows in a block, and if a query in a separate session requests the block,

     例如 一个未提交事物修改了一个块的两行,另一个session查询这个块

     then the database uses undo data to create a read-consistent version of this block (called a consistent read clone) that does not include the uncommitted updates.

     数据库使用undo,创建一个一致读版本的块(被称为一致读的块克隆),不包含未提交的update。

     Typically, a query retrieves blocks in consistent mode.
    典型的,查询在一致读模式下进行检索




本文出自 “道行尚浅(老道)的空间” 博客,请务必保留此出处http://daoye.blog.51cto.com/4190423/1431647

获得执行计划方法-一 ORACLE AUTOTRACE,布布扣,bubuko.com

获得执行计划方法-一 ORACLE AUTOTRACE

标签:获得执行计划方法

原文地址:http://daoye.blog.51cto.com/4190423/1431647

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!