原句为: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
先查询单表的,在查询关联表的数据