楼主: myfriend2010

这个sql怎么优化!

[复制链接]
论坛徽章:
21
在线时间
日期:2007-07-25 04:01:022012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:23马上有车
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:142012新春纪念徽章
日期:2012-02-13 15:09:23
91#
发表于 2008-5-12 15:35 | 只看该作者
原帖由 anlinew 于 2008-5-12 09:16 发表

举个特例 select * from a,b where a.col=b.col
而a,b的col    的值全为1,这样的sql最好的join 方式应该就是 Cartesian join 了,而Cartesian应该算作merge的一种特例
个人意见


Cartesian product, but no "Cartesian Join". Cartesian product can be processed by all the three join methods.

使用道具 举报

回复
求职 : 技术/实施/服务顾问
论坛徽章:
182
最佳人气徽章
日期:2012-03-13 17:39:18粉钻
日期:2012-07-03 19:48:12欧洲冠军杯纪念徽章
日期:2012-05-13 13:33:34菠菜明灯
日期:2012-05-13 13:33:35股神
日期:2012-05-13 13:33:35NBA之星
日期:2012-05-13 13:33:35NBA大富翁
日期:2012-05-13 13:33:35菠菜神灯
日期:2012-05-13 13:33:35ITPUB季度 社区新星
日期:2012-02-16 14:52:31奥运纪念徽章
日期:2008-09-04 11:35:05
92#
发表于 2008-5-12 16:12 | 只看该作者
帮顶

使用道具 举报

回复
论坛徽章:
21
在线时间
日期:2007-07-25 04:01:022012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:23马上有车
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:142012新春纪念徽章
日期:2012-02-13 15:09:23
93#
发表于 2008-5-13 22:13 | 只看该作者
Still not tested with different options? Theory is just theory, test is the only way to find out the right way for performance.

使用道具 举报

回复
招聘 : c/c++研发
论坛徽章:
45
技术图书徽章
日期:2014-03-10 14:09:192012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-01-04 11:51:22ITPUB十周年纪念徽章
日期:2011-11-01 16:21:15现任管理团队成员
日期:2011-05-07 01:45:082011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:41:50
94#
发表于 2008-5-14 06:36 | 只看该作者
i have another thoery that if creating an index with joint column and add all other required columns into INCLUDE clause, that may be able to help to avoid SORT operation
(the reason why creating index only on join column doesn't work, i beleive it may because optimizer thinks IXSCAN+FETCH is slower than SORT because of random access)

使用道具 举报

回复
招聘 : Linux运维
论坛徽章:
235
紫蜘蛛
日期:2007-09-26 17:05:46玉兔
日期:2007-09-26 17:05:05现任管理团队成员
日期:2011-05-07 01:45:08玉兔
日期:2006-08-29 20:38:48紫蜘蛛
日期:2007-09-26 17:05:34阿斯顿马丁
日期:2013-11-19 10:38:16奔驰
日期:2013-10-16 09:08:58红旗
日期:2014-01-09 11:57:39路虎
日期:2013-08-13 14:52:35林肯
日期:2015-05-19 13:01:16
95#
 楼主| 发表于 2008-5-14 08:13 | 只看该作者
原帖由 askgyliu 于 2008-5-13 22:13 发表
Still not tested with different options? Theory is just theory, test is the only way to find out the right way for performance.


老大,这2天西安闹地震,这边都放假了!!

使用道具 举报

回复
招聘 : Linux运维
论坛徽章:
235
紫蜘蛛
日期:2007-09-26 17:05:46玉兔
日期:2007-09-26 17:05:05现任管理团队成员
日期:2011-05-07 01:45:08玉兔
日期:2006-08-29 20:38:48紫蜘蛛
日期:2007-09-26 17:05:34阿斯顿马丁
日期:2013-11-19 10:38:16奔驰
日期:2013-10-16 09:08:58红旗
日期:2014-01-09 11:57:39路虎
日期:2013-08-13 14:52:35林肯
日期:2015-05-19 13:01:16
96#
 楼主| 发表于 2008-5-14 08:14 | 只看该作者
原帖由 wangzhonnew 于 2008-5-14 06:36 发表
i have another thoery that if creating an index with joint column and add all other required columns into INCLUDE clause, that may be able to help to avoid SORT operation
(the reason why creating index only on join column doesn't work, i beleive it may because optimizer thinks IXSCAN+FETCH is slower than SORT because of random access)



INCLUDE 那么多列,会不会巨占空间

使用道具 举报

回复
招聘 : c/c++研发
论坛徽章:
45
技术图书徽章
日期:2014-03-10 14:09:192012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-01-04 11:51:22ITPUB十周年纪念徽章
日期:2011-11-01 16:21:15现任管理团队成员
日期:2011-05-07 01:45:082011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:41:50
97#
发表于 2008-5-14 09:58 | 只看该作者
possible, but given there's seems no other good way to go, maybe it's worth to try this appraoch~~~

使用道具 举报

回复
招聘 : Java研发
论坛徽章:
71
马上加薪
日期:2014-02-19 11:55:14蜘蛛蛋
日期:2012-12-26 18:16:01茶鸡蛋
日期:2012-11-16 08:12:48ITPUB 11周年纪念徽章
日期:2012-10-09 18:05:07奥运会纪念徽章:网球
日期:2012-08-23 14:58:08奥运会纪念徽章:沙滩排球
日期:2012-07-19 17:28:14版主2段
日期:2012-07-07 02:21:02咸鸭蛋
日期:2012-03-23 18:17:482012新春纪念徽章
日期:2012-02-13 15:13:512012新春纪念徽章
日期:2012-02-13 15:13:51
98#
发表于 2008-5-14 15:43 | 只看该作者
原帖由 wangzhonnew 于 2008-5-14 09:58 发表
possible, but given there's seems no other good way to go, maybe it's worth to try this appraoch~~~

有没有简单办法让它走hash join?

使用道具 举报

回复
招聘 : Linux运维
论坛徽章:
235
紫蜘蛛
日期:2007-09-26 17:05:46玉兔
日期:2007-09-26 17:05:05现任管理团队成员
日期:2011-05-07 01:45:08玉兔
日期:2006-08-29 20:38:48紫蜘蛛
日期:2007-09-26 17:05:34阿斯顿马丁
日期:2013-11-19 10:38:16奔驰
日期:2013-10-16 09:08:58红旗
日期:2014-01-09 11:57:39路虎
日期:2013-08-13 14:52:35林肯
日期:2015-05-19 13:01:16
99#
 楼主| 发表于 2008-5-14 16:43 | 只看该作者
原帖由 anlinew 于 2008-5-14 15:43 发表

有没有简单办法让它走hash join?



有啊!
http://www.itpub.net/thread-917931-1-1.html

就是费事!

使用道具 举报

回复
招聘 : Linux运维
论坛徽章:
235
紫蜘蛛
日期:2007-09-26 17:05:46玉兔
日期:2007-09-26 17:05:05现任管理团队成员
日期:2011-05-07 01:45:08玉兔
日期:2006-08-29 20:38:48紫蜘蛛
日期:2007-09-26 17:05:34阿斯顿马丁
日期:2013-11-19 10:38:16奔驰
日期:2013-10-16 09:08:58红旗
日期:2014-01-09 11:57:39路虎
日期:2013-08-13 14:52:35林肯
日期:2015-05-19 13:01:16
100#
 楼主| 发表于 2008-5-21 13:19 | 只看该作者
to askgyliu:结果出来了
对于DMS:执行哪个测试
4561588 rows inserted in 1909.23 secs.
对于SMS:执行哪个测试
-- 4561588 rows inserted in 1997.53 secs.
中间测试的时候有停掉数据库的过程,所以数据缓冲区和sql解析的因素可以忽略!

使用道具 举报

回复

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

本版积分规则 发表回复

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