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

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


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扫描是最快的访问数据方式

标签:ORACLE,执行计划
0
投稿

猜你喜欢

  • 基于vue-resource jsonp跨域问题的解决方法

    2023-07-02 16:33:44
  • python面向对象入门教程之从代码复用开始(一)

    2022-07-17 21:54:13
  • Sql Server表死锁的解决方法分享

    2011-09-01 19:08:00
  • 解决使用layui对select append元素无效或者未及时更新的问题

    2024-04-16 09:27:43
  • python中实现字符串翻转的方法

    2021-06-08 04:27:59
  • 浅谈Django 页面缓存的cache_key是如何生成的

    2022-03-20 09:53:02
  • Python中的套接字编程是什么?

    2021-02-28 12:46:01
  • Nodejs之TCP服务端与客户端聊天程序详解

    2024-05-03 15:55:48
  • python2 对excel表格操作完整示例

    2022-08-27 00:35:06
  • Anaconda超详细保姆级安装配置教程

    2022-09-06 08:11:50
  • php基于curl主动推送最新内容给百度收录的方法

    2023-11-22 04:46:44
  • python开发之基于thread线程搜索本地文件的方法

    2023-05-11 18:49:12
  • 解剖JavaScript中的null和undefined

    2009-03-01 12:49:00
  • MySQL学习笔记之数据的增、删、改实现方法

    2024-01-27 04:07:41
  • opencv实现图像旋转效果

    2023-07-17 13:28:40
  • vue 无法覆盖vant的UI组件的样式问题

    2024-05-13 09:44:23
  • vue下拉菜单组件(含搜索)的实现代码

    2024-05-09 15:18:57
  • Python和perl实现批量对目录下电子书文件重命名的代码分享

    2022-01-28 02:51:48
  • Pytorch中torch.argmax()函数使用及说明

    2021-11-24 14:49:31
  • Python fileinput模块使用介绍

    2023-08-22 14:32:12
  • asp之家 网络编程 m.aspxhome.com