云蹦迪源码下载记⼀次MySQL多表联查时多个leftjoin优化从以前的30s左右到优化后的0.07s,速度嗖嗖的,原sql及具体优化如下:
mysql面试题sql语句多表联查--⽅法⼀:
SELECT s.id ,s.title
FROM school s
LEFT JOIN area_school_link asl ON s.id = asl.school_id
execution riskLEFT JOIN sys_area t1 ON asl.area_id = t1.id
LEFT JOIN sys_area t2 ON t1.parent_id = t2.id
WHERE s.deleted =0 and (t2.id =27 or t1.id =27)
--原先代码执⾏31s
饿了吗ui
SELECT s.id ,s.title
FROM school s INNER JOIN (SELECT a.area_id,a.school_id FROM area_school_link a) b ON s.id = b.school_id        LEFT JOIN sys_area t1 ON b.area_id = t1.id
LEFT JOIN sys_area t2 ON t1.parent_id = t2.id
winform textview 边框WHERE s.deleted =0 and (t2.id =27 or t1.id =27)
--优化后代码执⾏0.07s
--⽅法⼆:
--创建索引
create unique index index_id on school(id);
--删除索引
drop index index_id on school;
>inline在c语言中是什么意思

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。