像这种sql还有优化的余地吗。
两个表联查,都是几百万的数据,有没有优化的方法。
setect a.*
from table_a a,table_b b
where a.id = b.a_id
and b.code = 'name'
像这种sql还有优化的余地吗。
两个表联查,都是几百万的数据,有没有优化的方法。
setect a.*
from table_a a,table_b b
where a.id = b.a_id
and b.code = 'name'
1、table_b的a_id和code加索引
2、不要a.*,只查询出需要用到的字段
3、最好加分页 如果只查询一条 加上limit 1