专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > 高性能数据库开发

请教这个sql语句还能如何优化

发布时间:2010-05-24 21:18:39 文章来源:www.iduyao.cn 采编人员:星星草
请问这个sql语句还能怎么优化?

原句为:select * from table_b, table_a where (b.code="40" or b.code="41") and a.content=b.no and a.type='Po' and a.no=b.no
经修改并观测查询执行速度发现a.type='Po'过滤条件并没被优先执行,故改为:
select * from table_b, table_a where (b.code="40" or b.code="41") and a.type='Po' and a.content=b.no and a.no=b.no
还是觉得慢。
请问还能咋优化呢?
谢谢!


------解决方案--------------------
这两个表有什么连接关系?
------解决方案--------------------
可以试试这种方式,select * from table_b, table_a where a.type='Po' and a.content=a.no and (b.code="40" or b.code="41") and a.no=b.no 
先查询单表的,在查询关联表的数据
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: