帮忙看下这个mysql语句要如何优化
程序员文章站
2022-06-08 21:47:47
...
帮忙看下这个mysql语句要怎么优化
explain select SQL_CALC_FOUND_ROWS d.id,d.goodlevel,d.ismainfield,d.lirun,d.introduce,d.shen,d.city,d.mainfield,d.charges,d.type,m.indentity,m.nick as name,m.username,d.cxt_num,v.vnum
from tab1 as d left join tab2 as m on d.id=m.uid left join tab3 as v on d.id=v.uid order by d.goodlevel desc,d.cxt_num desc,v.vnum desc limit 10,10
------解决方案--------------------
不知道你的业务,不好改。上面说到索引,其实你这现在这个语句加不加索引也一样
from tab1 as d left join
==========================
d是左表,肯定是全表扫的。你的考虑下你的实际情况是不是需要tab1的整表数据。
explain select SQL_CALC_FOUND_ROWS d.id,d.goodlevel,d.ismainfield,d.lirun,d.introduce,d.shen,d.city,d.mainfield,d.charges,d.type,m.indentity,m.nick as name,m.username,d.cxt_num,v.vnum
from tab1 as d left join tab2 as m on d.id=m.uid left join tab3 as v on d.id=v.uid order by d.goodlevel desc,d.cxt_num desc,v.vnum desc limit 10,10
------解决方案--------------------
不知道你的业务,不好改。上面说到索引,其实你这现在这个语句加不加索引也一样
from tab1 as d left join
==========================
d是左表,肯定是全表扫的。你的考虑下你的实际情况是不是需要tab1的整表数据。
相关文章
相关视频
下一篇: spring boot 集成 redis