楼主: SunnyXu

[精华] 通过分析SQL语句的执行计划优化SQL(总结)

[复制链接]
招聘 : 技术支持/维护
论坛徽章:
1
会员2006贡献徽章
日期:2006-04-17 13:46:34
111#
发表于 2006-4-12 21:06 | 只看该作者
学习一下

使用道具 举报

回复
论坛徽章:
20
数据库板块每日发贴之星
日期:2006-03-21 01:01:20生肖徽章:猴
日期:2007-05-22 13:43:41生肖徽章:鸡
日期:2007-05-22 13:43:55生肖徽章:狗
日期:2007-05-22 13:44:08生肖徽章:猪
日期:2007-05-22 13:44:25会员2007贡献徽章
日期:2007-09-26 18:42:10生肖徽章2007版:鸡
日期:2008-01-02 17:35:53生肖徽章2007版:猴
日期:2008-01-02 17:35:53生肖徽章2007版:鼠
日期:2008-01-02 17:35:53生肖徽章:羊
日期:2007-05-22 13:43:25
112#
发表于 2006-4-14 15:41 | 只看该作者
str_sql string;
int_empno int;
int_empno = 2000;
str_sql = ‘SELECT * FROM emp WHERE empno = ‘ + int_empno;
…………
int_empno = 1000;
str_sql = ‘SELECT * FROM emp WHERE empno = ‘ + int_empno;
为什么说以上两句话不一样呢?
还有什么硬编码SQL??

使用道具 举报

回复
论坛徽章:
4
授权会员
日期:2007-09-19 15:15:31ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44ITPUB北京2009年会纪念徽章
日期:2009-02-09 11:42:45优秀写手
日期:2013-12-18 09:29:16
113#
发表于 2006-4-14 15:52 | 只看该作者
非常感谢!向你学习!

使用道具 举报

回复
论坛徽章:
0
114#
 楼主| 发表于 2006-4-19 13:47 | 只看该作者
对文中一句话的解释:
An Index full scan will not perform single block i/o's and so it may prove to be inefficient. (from metalink “Interpreting Explain plan”)

从metalink上找到了对这句话的进一步解释:
An Index full scan will perform single block i/o's and so under certain circumstances it be inefficient. Index Fast Full Scan will read using multiblock I/O. Range Scan can be used when the indexed column is used in the predicate. This may be more efficient depending on the amount of data the query retrieves.
Index full scan is the equivilant to a full table scan on an index. The columns needed are all contained in the index so it is faster to do a full index scan than a full table scan. 这一段是说明Index full scan为什么被证明为inefficient,因为该操作要读取索引中中全部数据,类似于全表扫描。不过它能利用多块读与并行读。

使用道具 举报

回复
论坛徽章:
151
2014年新春福章
日期:2014-04-17 11:38:13奥运会纪念徽章:皮划艇静水
日期:2012-07-31 15:42:58奥运会纪念徽章:田径
日期:2012-07-10 16:21:10奥运会纪念徽章:跆拳道
日期:2012-06-20 22:07:29奥运会纪念徽章:皮划艇静水
日期:2012-06-16 02:55:21奥运会纪念徽章:曲棍球
日期:2012-06-13 10:09:19蛋疼蛋
日期:2012-05-19 23:20:41迷宫蛋
日期:2012-05-16 17:35:25版主2段
日期:2012-05-15 15:24:11双黄蛋
日期:2012-03-19 19:34:04
115#
发表于 2006-4-19 13:56 | 只看该作者
最初由 SunnyXu 发布
[B]对文中一句话的解释:
An Index full scan will not perform single block i/o's and so it may prove to be inefficient. (from metalink “Interpreting Explain plan”)

从metalink上找到了对这句话的进一步解释:
An Index full scan will perform single block i/o's and so under certain circumstances it be inefficient. Index Fast Full Scan will read using multiblock I/O. Range Scan can be used when the indexed column is used in the predicate. This may be more efficient depending on the amount of data the query retrieves.
Index full scan is the equivilant to a full table scan on an index. The columns needed are all contained in the index so it is faster to do a full index scan than a full table scan. 这一段是说明Index full scan为什么被证明为inefficient,因为该操作要读取索引中中全部数据,类似于全表扫描。不过它能利用多块读与并行读。 [/B]


这个理解有误,index full scan一次只能读取一个块,且结果要按排序结果出来的;index fast full scan才会一次读取多个块的,跟FTS一样,按db_file_multilblock_read_count来读取的,按extent中块的顺序,不管列的排序。

使用道具 举报

回复
论坛徽章:
151
2014年新春福章
日期:2014-04-17 11:38:13奥运会纪念徽章:皮划艇静水
日期:2012-07-31 15:42:58奥运会纪念徽章:田径
日期:2012-07-10 16:21:10奥运会纪念徽章:跆拳道
日期:2012-06-20 22:07:29奥运会纪念徽章:皮划艇静水
日期:2012-06-16 02:55:21奥运会纪念徽章:曲棍球
日期:2012-06-13 10:09:19蛋疼蛋
日期:2012-05-19 23:20:41迷宫蛋
日期:2012-05-16 17:35:25版主2段
日期:2012-05-15 15:24:11双黄蛋
日期:2012-03-19 19:34:04
116#
发表于 2006-4-19 14:01 | 只看该作者
关于Index full scan&index fast full scan可以参考wanghai的文章:
http://spaces.msn.com/wzwanghai/ ... 37AFBD116!171.entry

使用道具 举报

回复
论坛徽章:
20
数据库板块每日发贴之星
日期:2006-03-21 01:01:20生肖徽章:猴
日期:2007-05-22 13:43:41生肖徽章:鸡
日期:2007-05-22 13:43:55生肖徽章:狗
日期:2007-05-22 13:44:08生肖徽章:猪
日期:2007-05-22 13:44:25会员2007贡献徽章
日期:2007-09-26 18:42:10生肖徽章2007版:鸡
日期:2008-01-02 17:35:53生肖徽章2007版:猴
日期:2008-01-02 17:35:53生肖徽章2007版:鼠
日期:2008-01-02 17:35:53生肖徽章:羊
日期:2007-05-22 13:43:25
117#
发表于 2006-4-19 17:49 | 只看该作者
最初由 SunnyXu 发布
[B]对文中一句话的解释:
An Index full scan will not perform single block i/o's and so it may prove to be inefficient. (from metalink “Interpreting Explain plan”)

从metalink上找到了对这句话的进一步解释:
An Index full scan will perform single block i/o's and so under certain circumstances it be inefficient. Index Fast Full Scan will read using multiblock I/O. Range Scan can be used when the indexed column is used in the predicate. This may be more efficient depending on the amount of data the query retrieves.
Index full scan is the equivilant to a full table scan on an index. The columns needed are all contained in the index so it is faster to do a full index scan than a full table scan. 这一段是说明Index full scan为什么被证明为inefficient,因为该操作要读取索引中中全部数据,类似于全表扫描。不过它能利用多块读与并行读。 [/B]

在这句话中应该没有NOT才对。
An Index full scan will not perform single block i/o's and so it may prove to be inefficient. (from metalink “Interpreting Explain plan”)
可以查看原文Interpreting Explain plan
http://www.akadia.com/services/ora_interpreting_explain_plan.html

使用道具 举报

回复
论坛徽章:
0
118#
发表于 2006-4-19 18:37 | 只看该作者
收藏学习中,感觉楼主的辛勤劳动。

使用道具 举报

回复
论坛徽章:
8
授权会员
日期:2005-10-30 17:05:33ITPUB元老
日期:2007-10-04 13:18:29ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:42一汽
日期:2013-11-01 11:06:26
119#
发表于 2006-4-21 09:55 | 只看该作者

好文,

精彩!

使用道具 举报

回复
论坛徽章:
168
马上加薪
日期:2014-02-19 11:55:142012新春纪念徽章
日期:2012-02-13 15:10:582012新春纪念徽章
日期:2012-01-04 11:49:54蜘蛛蛋
日期:2011-12-05 16:08:56ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41设计板块每日发贴之星
日期:2011-07-22 01:01:02ITPUB官方微博粉丝徽章
日期:2011-06-30 12:30:16管理团队成员
日期:2011-05-07 01:45:082011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:33
120#
发表于 2006-4-21 11:31 | 只看该作者

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表