首页新闻找找看学习计划

MySQL语句优化,不考虑索引方面的,只考虑优化这个SQL语句

0
悬赏园豆:10 [已关闭问题] 关闭于 2017-08-21 09:16

SQL语句优化,不考虑索引方面的,只考虑优化这个SQL语句

复制代码
SELECT
    u. NAME AS '老师姓名',
    count(1) AS '讲议数量',
    ls.lesson_plan_id,
    ls.student_id,
    ls.teacher_id,
    ls.subject_id
FROM
    lesson_plan ls
INNER JOIN lesson_plan_quiz lq ON lq.lesson_plan_id = ls.lesson_plan_id 
-- AND ls.adjust_start_time LIKE '2017-07-13%' 
-- AND ls.adjust_start_time >= '2017-07-13'
-- AND ls.adjust_start_time <= '2017-07-13 23:59:59' 
-- AND DATE(ls.adjust_start_time) = '2017-07-13'
-- and DATEDIFF(ls.adjust_start_time,'2017-07-13')=0
-- AND ls.adjust_start_time BETWEEN '2017-07-13 00:00:00' AND '2017-07-13 23:59:59'
AND ls.solve_status = 5
AND ls.lesson_type = 1
AND ls.`status` = 3
AND DATE(ls.adjust_start_time) = '2017-07-13'
LEFT JOIN user_info u ON ls.teacher_id = u.user_id
GROUP BY
    u. NAME,
    ls.lesson_plan_id,
    ls.student_id,
    ls.teacher_id,
    ls.subject_id
ORDER BY
    count(1) DESC
复制代码

请问优化点有哪些?

SQL
再见2019的主页 再见2019 | 专家六级 | 园豆:11871
提问于:2017-08-18 16:17
< >
分享
所有回答(1)
0

AND ls.solve_status = 5 AND ls.lesson_type = 1 AND ls.`status` = 3 AND DATE(ls.adjust_start_time) = '2017-07-13'

这些,我觉得应该是where条件中的

金琥 | 园豆:2560 (老鸟四级) | 2017-08-18 17:06
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册