首页 > 数据库

使用dbms_xplan工具查看执行计划

时间:2009-04-28 15:17:43  作者:cathysun118  我要投稿
Linux初探欢迎您的投稿,投放方法请点击这里查看,我们会定期赠送精美小礼品给优秀的投稿作者。海纳百川 取则行远!LinuxGoo欢迎您的到来。
使用dbms_xplan工具查看执行计划9i有一个新的包 dbms_xplan,对查询plan_table表是一个很有用的工具,相对于以前写一个复杂的SQL语句,然后从plan_table看执行计划,......

使用dbms_xplan工具查看执行计划

9i有一个新的包 dbms_xplan,对查询plan_table表是一个很有用的工具,相对于以前写一个复杂的SQL语句,然后从plan_table看执行计划,不如调用 dbms_xplan 包,还可以显示格式,这个工具的使用也非常方便。
调用的语法类似
select * from table(dbms_xplan.display(format=>'BASIC'))
使用 TABLE() 操作符,或者 CAST 操作。

DISPLAY 函数有三个参数
TABLE_NAME 指出优化计划放在哪个表里面,默认是 PLAN_TABLE.
STATEMENT_ID 指的是plan table中的statement_id字段,默认是last ID 或者 NULL.
FORMAT 指的是显示的格式


FORMAT参数有三个可选值,原文如下
BASIC It provides only the minimum amount of information, as in
case of the example above, similar to a query from
PLAN_TABLE directly.
TYPICAL This is the default value. It provides a variety of the
information useful for understanding how the optimizer
works for this statement. For instance, in case of partitioned
table operation, the columns PARTITION_START,
PARTITION_STOP, PARTITION_ID, and
FILTER_PREDICATES are displayed in addition to COST
for that step, the number of rows expected to be retrieved,
and number of bytes those rows may have. This provides
the information to understand statements involving
partitioned objects.
ALL This setting displays all the information displayed for the
BASIC and TYPICAL values, and also displays parallel
query operations and the related SQL statements, if those
are involved.
SERIAL This setting gets results similar to those retrieved by the
TYPICAL setting, but the queries are explained serially even
if a parallel query will be used.

一般推荐使用typical 参数,把SQLPLUS的linesize 参数调整到至少 120

下面是测试步骤

用sys用户建立
PLUSTRACE 角色
$ORACLE_HOME\E:\oracle\ora92\sqlplus\admin\Plustrce.sql

二:把权限授予某个人
grant plustrace to mjs;

三:建立表
建表SQL脚本为在${ORACLE_HOME}/rdbms/admin/下的utlxplan.sql。

如果您需转载 使用dbms_xplan工具查看执行计划,请注明来自LinuxGoo.com,其版权归原作者所有。请广大网友留言时遵纪守法,使用文明用语。如果您在应用中有什么问题,请在下面留言,我们会尽快解答。
来顶一下
近回首页
返回首页
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
相关文章
栏目热门