当前位置: 代码迷 >> 高性能数据库开发 >> 请教这个sql语句还能如何优化
  详细解决方案

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

热度:7330   发布时间:2013-02-26 00:00:00.0
请问这个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 
先查询单表的,在查询关联表的数据
  相关解决方案