sql优化(未优化成功)
SELECT
t.id,
t.section_id sectionId,
t.person_id personId,
t.phone,
sec.section_name sectionName,
pi.person_name personName,
t4.DICTNAME as persionPosition,
t3.DICTNAME as personType,
IF(t.state='1',"未处理",IF(t.state='2',"已处理","")) AS state,
t.clock_time clockTime
FROM
(SELECT aal.*,person_category from cp_person_card pc
left JOIN cp_attend_abnormal_log aal on pc.person_id = aal.person_id
and aal.section_id = pc.section_id) t
left JOIN cp_person_info pi on pi.id = t.person_id
LEFT JOIN (SELECT * FROM t_dict WHERE DICTHEADID='PERSON_CATEGORY' )t3 on t.person_category=t3.DICTID
LEFT JOIN (SELECT DICTNAME,DICTID FROM t_dict WHERE DICTHEADID='PROJECT_DEPARTMENT_CATEGORY')t4 on t.persion_position=t4.DICTID
LEFT JOIN cp_proj_section sec ON t.section_id = sec.section_id
explain分析

索引都加了,不知道怎么优化...........先记录一下

浙公网安备 33010602011771号