网络编程
位置:首页>> 网络编程>> 数据库>> ORACLE数据库查看执行计划的方法(4)

ORACLE数据库查看执行计划的方法(4)

 来源:asp之家 发布时间:2012-06-06 20:15:52 

标签:ORACLE,执行计划

3.具体内容查看
1> Plan hash Value
这一行是这一条语句的的hash值,我们知道ORACLE对每一条ORACLE语句产生的执行计划放在SHARE POOL里面,第一次要经过硬解析,产生hash值。下次再执行时比较hash值,如果相同就不会执行硬解析。
2> COST

COST没有单位,是一个相对值,是SQL以CBO方式解析执行计划时,供ORACLE来评估CBO成本,选择执行计划用的。没有明确的含义,但是在对比是就非常有用。
公式:COST=(Single Block I/O COST + MultiBlock I/O Cost + CPU Cost)/ Sreadtim

3> 对上面执行计划列字段的解释:
Id: 执行序列,但不是执行的先后顺序。执行的先后根据Operation缩进来判断(采用最右最上最先执行的原则看层次关系,在同一级如果某个动作没有子ID就最先执行。一般按缩进长度来判断,缩进最大的最先执行,如果有2行缩进一样,那么就先执行上面的。)
    Operation:当前操作的内容。
    Name:操作对象
    Rows:也就是10g版本以前的Cardinality(基数),Oracle估计当前操作的返回结果集行数。
    Bytes:表示执行该步骤后返回的字节数。
    Cost(CPU):表示执行到该步骤的一个执行成本,用于说明SQL执行的代价。
    Time:Oracle 估计当前操作的时间。
4.谓词说明:
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("B"."MGR" IS NOT NULL)
4 - access("A"."EMPNO" = "B"."MGR")
    Access: 表示这个谓词条件的值将会影响数据的访问路劲(全表扫描还是索引)。
    Filter:表示谓词条件的值不会影响数据的访问路劲,只起过滤的作用。
    在谓词中主要注意access,要考虑谓词的条件,使用的访问路径是否正确。
5、 动态分析
如果在执行计划中有如下提示:
Note
------------
-dynamic sampling used for the statement
这提示用户CBO当前使用的技术,需要用户在分析计划时考虑到这些因素。 当出现这个提示,说明当前表使用了动态采样。我们从而推断这个表可能没有做过分析。
这里会出现两种情况:
(1) 如果表没有做过分析,那么CBO可以通过动态采样的方式来获取分析数据,也可以或者正确的执行计划。
(2) 如果表分析过,但是分析信息过旧,这时CBO就不会在使用动态采样,而是使用这些旧的分析数据,从而可能导致错误的执行计划。

四、表访问方式

1.Full Table Scan (FTS) 全表扫描

2.Index Lookup 索引扫描
There are 5 methods of index lookup:
index unique scan --索引唯一扫描
通过唯一索引查找一个数值经常返回单个ROWID,如果存在UNIQUE或PRIMARY KEY约束(它保证了语句只存取单行的话),ORACLE
经常实现唯一性扫描
Method for looking up a single key value via a unique index. always returns a single value, You must supply AT LEAST the leading column of the index to access data via the index.
index range scan --索引局部扫描
Index range scan is a method for accessing a range values of a particular column. AT LEAST the leading column of the index must be supplied to access data via the index. Can be used for range operations (e.g. > < <> >= <= between) .
使用一个索引存取多行数据,在唯一索引上使用索引范围扫描的典型情况是在谓词(WHERE 限制条件)中使用了范围操作符号(如>, < <>, >=, <=,BWTEEN)
index full scan --索引全局扫描
Full index scans are only available in the CBO as otherwise we are unable to determine whether a full scan would be a good idea or not. We choose an index Full Scan when we have statistics that indicate that it is going to be more efficient than a Full table scan and a sort. For example we may do a Full index scan when we do an unbounded scan of an index and want the data to be ordered in the index order.
index fast full scan --索引快速全局扫描,不带order by情况下常发生
Scans all the block in the index, Rows are not returned in sorted order, Introduced in 7.3 and requires V733_PLANS_ENABLED=TRUE and CBO, may be hinted using INDEX_FFS hint, uses multiblock i/o, can be executed in parallel, can be used to access second column of concatenated indexes. This is because we are selecting all of the index.
index skip scan --索引跳跃扫描,where条件列是非索引的前提情况下常发生
Index skip scan finds rows even if the column is not the leading column of a concatenated index. It skips the first column(s) during the search.
3.Rowid 物理ID扫描
This is the quickest access method available.Oracle retrieves the specified block and extracts the rows it is interested in. --Rowid扫描是最快的访问数据方式

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com