我已经在这件事上好几个小时了。有没有人对如何加快查询速度有任何想法?
SELECT SQL_CALC_FOUND_ROWS
mdl_course.fullname as course_name,
mdl_course.idnumber as course_length,
mdl_user.firstname as firstname,
mdl_user.lastname as lastname,
case when mdl_course_completions.timecompleted IS NOT NULL
then FROM_UNIXTIME(mdl_course_completions.timecompleted,'%m/%d/%Y') else 'N/A' end AS date_completed,
mdl_cohort.name AS group_name,
mdl_course_categories.name as category_name,
case when mdl_course_completions.timecompleted IS NOT NULL then 'Completed' else
'Incomplete' end AS completion_status
FROM mdl_enrol
JOIN mdl_user_enrolments ON mdl_user_enrolments.enrolid = mdl_enrol.id
JOIN mdl_course ON mdl_course.id = mdl_enrol.courseid
JOIN mdl_user ON mdl_user.id = mdl_user_enrolments.userid AND mdl_user.deleted = 0
JOIN mdl_cohort_members ON mdl_cohort_members.userid = mdl_user.id
JOIN mdl_cohort ON mdl_cohort.id = mdl_cohort_members.cohortid
JOIN mdl_course_categories ON mdl_course_categories.id = mdl_course.category
JOIN mdl_course_completions ON mdl_course_completions.course = mdl_course.id
AND mdl_course_completions.userid = mdl_user.id
AND mdl_course_completions.deleted IS NULL
GROUP BY mdl_course_completions.id
ORDER BY mdl_course.fullname ASC
mdl_course_completions中有超过100,000行,并且正在减慢所有内容。