MySQL社区

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
查看: 4953|回复: 1
打印 上一主题 下一主题

许多oracle的优化规则 在mysql失效--探讨优化

[复制链接]
跳转到指定楼层
1#
发表于 2009-6-12 14:37:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
许多oracle的优化规则 在mysql失效--探讨优化

比如
select * from Outcome_history where eventId not in (select id from Event_history)
我执行得到结果时间为 0.267s

如果按照常规数据库优化 必须将not in换成not exist
select * from Outcome_history  where  not EXISTS  (select id from Event_history where Event_history.id=Outcome_history.eventId)
0.266s (有时会是0.297,这是第1次执行的时间,后来的因为缓存就快了)

再换
select * from Outcome_history  a where  not EXISTS  (select b.id from Event_history b where b.id=a.eventId)
0.281s  (为什么mysql加上别名会慢上很多 ,很奇特的现象 ?? 这2个表都很大,第1表17万,第2条10万条)


如果是这样,exists存在就是为了走索引,没有索引他不会加快速度,在mysql确实跟其他数据库有点不同 。欢迎跟帖讨论。
有兴趣我再贴企业级优化例子
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏 分享淘帖 顶 踩
2#
发表于 2012-8-2 12:18:35 | 只看该作者
谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|申请友链|小黑屋|Archiver|手机版|MySQL社区 ( 京ICP备07012489号   
联系人:周生; 联系电话:13911732319

GMT+8, 2024-5-18 05:19 , Processed in 0.066032 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表