我在我的moodle网站上使用下面给出的自定义查询并且工作正常但是现在mdl_user_enrollments表中的总记录是3000万,这需要时间将结果返回到我的前端屏幕。请让我知道如何加快速度。
下面的查询
select t1.userid,t2.courseid AS course_id, t1.timestart AS subscription_start, t1.timeend AS subscription_end,t1.timecreated AS timecreated,t1.timemodified AS timemodified, t3.id AS quiz_id,
t3.name AS quiz_name from mdl_user_enrolments t1
join mdl_enrol t2 on t1.userid=$user_id and t1.enrolid = t2.id
join mdl_quiz t3 on t3.course = t2.courseid
解释输出
Explain mdl_user_enrolments result
Field Type Null Key Default Extra
id bigint(10) NO PRI NULL auto_increment
status bigint(10) NO 0
enrolid bigint(10) NO MUL NULL
userid bigint(10) NO MUL NULL
timestart bigint(10) NO 0
timeend bigint(10) NO 2147483647
modifierid bigint(10) NO MUL 0
timecreated bigint(10) NO 0
timemodified bigint(10) NO 0
分析表mdl_user_enrolments结果
表操作Msg_type Msg_text eLearningDev_v1.mdl_user_enrolments分析状态确定
表格大小mdl_user_enrolments 910 MB
答案 0 :(得分:0)
Select t1.userid,t2.courseid AS course_id, t1.timestart AS subscription_start, t1.timeend AS subscription_end,t1.timecreated AS timecreated,t1.timemodified AS timemodified, t3.id AS quiz_id,
t3.name AS quiz_name from mdl_user_enrolments t1
LEFT join mdl_enrol AS t2 on t1.userid=$user_id and t1.enrolid = t2.id
LEFT join mdl_quiz AS t3 on t3.course = t2.courseid
希望这对你有用。