• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

查看执行计划方法总结之一:explain plan命令

mysql 搞代码 4年前 (2022-01-09) 23次浏览 已收录 0个评论

查看执行计划的方法有很多种,笔者今后将在博客里一一为大家介绍。本文介绍的是第一种方法,利用explain plan命令来查看执行计划

查看执行计划的方法有很多种,笔者今后将在博客里一一为大家介绍。本文介绍的是第一种方法,利用explain plan命令来查看执行计划。

1.用hr用户登录数据库
[Oracle@ENMOEDU ~]$ sqlplus hr/oracle@ENMOEDU

SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 10 00:11:00 2014
Copyright (c) 1982, 2011, Oracle.本文来源gao@!dai!ma.com搞$$代^@码!网 All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

HR@ENMOEDU >

2.使用explain plan命令
HR@ENMOEDU > explain plan for select salary from employees where first_name like ‘Pat’;

Explained.

3.查看执行计划
HR@ENMOEDU > select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
————————————————————————
Plan hash value: 3033625502
——————————————————————————————-
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
——————————————————————————————-
| 0 | SELECT STATEMENT | | 1 | 11 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| EMPLOYEES | 1 | 11 | 2 (0)| 00:00:01 |
|* 2 | INDEX SKIP SCAN | EMP_NAME_IX | 1 | | 1 (0)| 00:00:01 |
——————————————————————————————-
Predicate Information (identified by operation id):
—————————————————
2 – access(“FIRST_NAME”=’Pat’)
filter(“FIRST_NAME”=’Pat’)

15 rows selected.

至此,,执行计划查看成功。


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:查看执行计划方法总结之一:explain plan命令

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址