动态网站制作指南 [  QQ表情  ]
[ 投票调查 ]
[ 企业邮箱 ]
[ 网站空间 ]
网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
ASP源码 | .Net源码 | PHP源码 | JSP源码 | JAVA源码 | CGI源码 | VB源码 | C++源码 | Delphi源码 | PB源码 | VF源码 | 汇编 | 服务器
电脑书籍下载:程序设计书籍 | 数据库教程书籍 | 平面与多媒体书籍 | 网络通讯书籍 | 系统管理书籍 | 网络安全书籍 | 认证考试书籍
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > 数据库 > Oracle教程
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
数据库:数据库教程,数据库技巧,Oracle教程,MySQL教程,Sybase教程,Access教程,DB2教程,数据库安全,数据库文摘
文章搜索服务
邮件订阅
输入你的邮件地址,
你将不会错过任何关于:
[ Oracle教程 ]的信息



本月文章推荐
.数据库在网格计算中的角色.
.linux可以绕开三茗硬盘保护卡.
.如何找出磁盘中某个大小范围内的.
.Oracle数据库技术(36).
.查看各个表空间占用磁盘情况.
.UNIX工作站对远程ORACLE FOR Net.
.Oracle数据库启动监听器不启动或.
.移动设备的应用开发平台---J2ME简.
.打开和关闭数据库的过程.
.Oracle 10月份发表的一系列漏洞.
.分区的情况下,对insert速度影响.
.PL/SQL入门.
.一起学习在linux下使用汇编语言(.
.Windows XP下安装Oracle9i问题二.
.ORACLE性能调优原则.
.程序员如何掌握计算机英语.
.Sun推出T1服务器 Oracle顾客受益.
.oracle 常用SQL查询,望对大家有.
.死联接检测(DCD)的探讨与研究.
.数据库安全性策略.

关于如何理解Explain Plan的输出

发表日期:2008-2-9 |



  关于怎样解释EXPlain的输出曾经一直是一个困扰我的问题,后来我在Metalink上找到这篇文章,顿时豁然开朗。
  希望有同样问题的同志能从这篇文章有所收获,曾经想翻译成中文,但实在没有时间,有心的同志可以试试。
  
  Interpreting Explain plan
  1. Background information
  1.1 What's an explain plan?
  ~~~~~~~~~~~~~~~~~~~~~~~
  An explain plan is a representation of the Access path that is taken when a query is executed within Oracle.
  
  Query processing can be divided into 7 phases:
  [1] Syntactic - checks the syntax of the query
  [2] Semantic - checks that all objects exist and are accessible
  [3] View Merging - rewrites query as join on base tables as
  opposed to using views
  [4] Statement Transformation - rewrites query transforming some complex
  constrUCts into simpler ones where
  appropriate (e.g. subquery unnesting, in/or
  transformation)
  [5] Optimization - determines the optimal access path for the
  query to take. With the Rule Based
  Optimizer (RBO) it uses a set of heuristics
  to determine access path. With the Cost
  Based Optimizer (CBO) we use statistics
  to analyze the relative costs of accessing
  objects.
  [6] QEP Generation
  [7] QEP Execution
  (QEP = Query Evaluation Plan)
  
  Steps [1]-[6] are handled by the parser.
  Step [7] is the execution of the statement.
  
  The explain plan is produced by the parser. Once the access path has been decided upon it is stored in the library cache together with the statement itself. We store queries in the library cache based upon a hashed representation of that query. When looking for a statement in the library cache, we first apply a hashing algorithm to the statement and then we look for this hash value in the library cache.
  This access path will be used until the query is reparsed.
  
  1.2 Terminology
  ~~~~~~~~~~~
  Row Source - a set of rows used in a query
  may be a select from a base object or the result set returned by
  joining 2 earlier row sources
  Predicate - where clause of a query
  Tuples - rows
  Driving Table - This is the row source that we use to seed the query.
  If this returns a lot of rows then this can have a negative
  affect on all subsequent operations
  Probed Table - This is the object we lookup data in after we have retrieved
  relevant key data from the driving table.
  
  1.3 How does Oracle access data?

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  At the physical level Oracle reads blocks of data. The smallest amount of data read is a single Oracle block, the largest is constrained by operating system limits (and multiblock i/o).
  Logically Oracle finds the data to read by using the following methods:
  Full Table Scan (FTS)
  Index Lookup (unique & non-unique)
  Rowid
  
  1.4 Explain plan Hierarchy
  ~~~~~~~~~~~~~~~~~~~~~~
  Simple explain plan:
  
  Query Plan
  -----------------------------------------
  SELECT STATEMENT [CHOOSE] Cost=1234
  TABLE ACCESS FULL LARGE [:Q65001] [ANALYZED]
  
  The rightmost uppermost operation of an explain plan is the first thing that the explain plan will execute. In this case TABLE ACCESS FULL LARGE is the first operation. This statement means we are doing a full table scan of table LARGE. When this operation completes then the resultant row source is passed up to the next level of the query for processing. In this case it is the SELECT STATEMENT which is the top of the query.
  [CHOOSE] is an indication of the optimizer_goal for the query. This DOES NOT necessarily indicate that plan has actually used this goal. The only way to confirm this is to check the cost= part of the explain plan as well. For example the following query indicates that the CBO has been used because there is a cost in the cost field:
  
  SELECT STATEMENT [CHOOSE] Cost=1234
  
  However the explain plan below indicates the use of the RBO because the cost field is blank:
  
  SELECT STATEMENT [CHOOSE] Cost=
  
  The cost field is a comparative cost that is used internally to determine the best cost for particular plans. The costs of different statements are not really directly comparable.
  [:Q65001] indicates that this particular part of the query is being executed in parallel. This number indicates that the operation will be processed by a parallel query slave as opposed to being executed serially.
  [ANALYZED] indicates that the object in question has been analyzed and there are currently statistics available for the CBO to use. There is no indication of the 'level' of analysis done.
  2. Access Methods in detail
  2.1 Full Table Scan (FTS)
  ~~~~~~~~~~~~~~~~~~~~~
  In a FTS operation, the whole table is read up to the high water mark (HWM). The HWM marks the last block in the table that has ever had data written to it. If you have deleted all the rows then you will still read up to the HWM. Truncate resets the HWM back to the start of the table.
  FTS uses multiblock i/o to read the blocks from disk. Multiblock i/o is controlled by the parameter . This defaults to:
  db_block_buffers / ( (PROCESSES+3) / 4 )
  Maximum values are OS dependant
  Buffers from FTS operations are placed on the Least Recently Used (LRU) end of the buffer cache so will be quickly aged out. FTS is not recommended for large tables unless you are reading >5-10% of it (or so) or you intend to run in parallel.
  
  Example FTS explain plan:
  ~~~~~~~~~~~~~~~~~~~~~~~~
  SQL> explain plan for select * from dual;

  Query Plan
  -----------------------------------------
  SELECT STATEMENT [CHOOSE] Cost=
  TABLE ACCESS FULL DUAL
  
  
  2.2 Index lookup
  ~~~~~~~~~~~~
  Data is accessed by looking up key values in an index and returning rowids. A rowid uniquely identifies an individual row in a particular data block. This block is read via single block i/o.
  In this example an index is used to find the relevant row(s) and then the table is accessed to lookup the ename column (which is not included in the index):
  
  SQL> explain plan for
  select empno,ename from emp where empno=10;
  Query Plan
  ------------------------------------
  SELECT STATEMENT [CHOOSE] Cost=1
  TABLE ACCESS BY ROWID EMP [ANALYZED]
  INDEX UNIQUE SCAN EMP_I1
  
  Notice the 'TABLE ACCESS BY ROWID' section. This indicates that the table data is not being accessed via a FTS operation but rather by a rowid lookup. In this case the rowid has been produced by looking up values in the index first.
  The index is being accessed by an 'INDEX UNIQUE SCAN' operation. This is explained below. The index name in this case is EMP_I1.
  If all the required data resides in the index then a table lookup may be unnecessary and all you will see is an index access with no table access.
  In the following example all the columns (empno) are in the index. Notice that no table access takes place:
  
  SQL> explain plan for
  select empno from emp where empno=10;
  Query Plan
  ------------------------------------
  SELECT STATEMENT [CHOOSE] Cost=1
  INDEX UNIQUE SCAN EMP_I1
  
  Indexes are presorted so sorting may be unnecessary if the sort order required is the same as the index.
  
  e.g.
  
  SQL> explain plan for select empno,ename from emp
  where empno > 7876 order by empno;
  
  Query Plan
  -----------------------------------------------------
上一篇:linux学习笔记:进程及作业 人气:537
下一篇:LMT下表FREELIST的初步探索 人气:346
浏览全部Oracle教程的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-7-24 Sablog-X v2.0 预览版
2008-7-24 帝国备份王EmpireBak 2008 正式版
2008-7-24 网趣网上购物系统时尚版 v8.2
2008-7-24 纵横B2B电子商务系统XYECS!B2B v
2008-7-24 e路小说小偷 v1.2.0723
2008-7-24 凌风美女图片站程序 v2.2
2008-7-24 TOM15电影收索程序
2008-7-24 清风信息自动采集生成系统 v1.0
2008-7-24 QQ邮箱编辑器 v1.0 (小小菜刀ASP
2008-7-19 UltraEdit 简体中文增强版 14.10
2008-7-19 CentOS 5.2 i386 LiveCD
2008-7-19 Snapture多功能相机 v1.4
2008-7-19 iAcces中文输入法 v1.0Build016
2008-7-19 Cookbook烹饪秘籍 v2.5
2008-7-19 苹果专用DVD转换工具 v1.1.59汉化
2008-7-19 Modem修复软件ZiPhone修改版04.0
2008-7-19 AgileMessenger即时通讯工具美化
2008-7-19 Sketches画图软件 v0.7b6破解版


  发表评论
姓 名: 验证码:
内 容:
[ 汉字翻译拼音 ] [ 广告代码 ] [ 符号对照表 ] [ 进制转换 ] [ 经典小工具 ] [ 个税计算 ] [ 汉字简繁转换 ] [ 普通单位换算 ] [ 公制单位换算 ]
[ 生辰老黄历 ] [ 国内电话区号 ] [ 国家代码与域名缩写 ] [ 文字加密解密 ] [ 健康查询 ] [ 万年历 ] [ 手机号码查询 ] [ ip搜索 ] [ Google PR查询 ]
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号
ホームページ制作 不動産検索システム 求人情報
防水工事·改修工事 フットサル大会 探偵