您实例CPU高的时候,有些全表扫描或者索引不合适的语句执行,建议您看下诊断报告,优化下。 缺少索引或者索引不合适: [ SELECT c.case_no AS caseNo, c.license_no AS licenseNo, c.damage_date AS damageDate, c.policy_code AS policyCode, o.org_name AS orgName, o.org_id AS orgId, l.create_time AS createTime, l.surveyor_code AS surveyorCode, l.surveyor_name AS surveyorName, l.auditor_code AS auditorCode, l.auditor_name AS auditorName, CASE WHEN l.claim_status = 1 THEN '未认领' ELSE '已认领' END AS claimStatus, CASE l.handle_status WHEN 0 THEN '未上传' WHEN 1 THEN '待审核' WHEN 2 THEN '审核完成' WHEN 4 THEN '退回未上传' WHEN 5 THEN '结案取消' WHEN 6 THEN '申请改派' WHEN 7 THEN '改派未上传' WHEN 8 THEN '主动认领' END as handleStatus, l.verify_time AS verifyTime FROM prpm_case_info_cyp c INNER JOIN prpm_org o ON c.org_code = o.org_code INNER JOIN prpm_loss_item_cyp l ON l.case_info_cyp_id = c.case_info_cyp_id AND l.create_time >= '2017-06-01 00:00:00' AND l.create_time <= '2017-06-20 23:59:59' ORDER BY l.create_time DESC limit 0,10 ] SELECT pf.surveyCaseNum, pt.selfCaseNum FROM ( SELECT COUNT(0) AS 'surveyCaseNum' FROM prpm_loss_item p WHERE (p.user_type = 1 OR p.user_type = 2) AND p.org_code = '0193' AND to_days(p.create_time) = to_days(now()) ) pf ,(SELECT COUNT(0) AS 'selfCaseNum' FROM prpm_loss_item p WHERE p.user_type = 3 AND p.org_code = '0193' AND to_days(p.create_time) = to_days(now())) pt SQL: select count ( 0 ) from prpm_image_survey pimg left join prpm_survey_user pcheck on pimg.survey_user_uuid = pcheck.survey_user_id join prpm_loss_item loss on pimg.loss_item_id = loss.loss_item_id where loss.loss_status in ( :1 , :2 ) and pimg.is_dealing = :3 and pimg.deal_flag = :4 and pcheck.survey_name is null and pcheck.valid_status = :5 and loss.org_code in ( select o.org_code from prpm_org o where o.org_id = :6 or o.org_pids like concat ( :7 , :8 , :9 ) ) 建议: 【 严重 】 扫描行与发送行的比是344,需要注意like可能无法使用索引,请优化表结构和SQL语句。 【 严重 】 该sql含有子查询,严重影响了查询性能,请改写sql,尝试去掉子查询,或者讲将查询改写为join。 【 严重 】 扫描行与发送行的比是344,并且使用了聚合函数,该SQL索引过滤性不好,影响服务器性能。 【 警告 】 您的SQL语句可能使用了MyISAM引擎,性能受到影响,请考虑换用InnoDB SQL: select pu.upload_image_id , pu.case_info_id , pu.loss_item_id , pu.case_no , pu.upload_time , pu.user_code , pu.mobile , pu.oss_key , pu.license_no , pu.shot_time , pu.shot_latitude , pu.shot_longitude , pu.img_name , pu.img_path , pu.img_type , pu.lock_flag , pu.break_point_flag , pu.stay_upload , pu.remark , pu.create_by , pu.create_time , pu.modify_by , pu.modify_time from prpm_upload_image pu where pu.upload_image_id in ( select ir.upload_image_id from prpm_item_img_rela ir where ir.loss_item_id in ( :1 , :2 ) ) and pu.break_point_flag = :3 order by pu.shot_time asc 建议: 【 严重 】 该sql含有子查询,严重影响了查询性能,请改写sql,尝试去掉子查询,或者讲将查询改写为join。 SQL: select pf.surveycasenum , pt.selfcasenum from ( select count ( 0 ) as 'surveycasenum' from prpm_loss_item p where ( p.user_type = :1 or p.user_type = :2 ) and p.org_code = :3 and to_days ( p.create_time ) = to_days ( now ( ) ) ) pf , ( select count ( 0 ) as 'selfcasenum' from prpm_loss_item p where p.user_type = :4 and p.org_code = :5 and to_days ( p.create_time ) = to_days ( now ( ) ) ) pt 建议: 【 严重 】 扫描行与发送行的比是171119,并且使用了聚合函数,该SQL索引过滤性不好,影响服务器性能。 SQL: select pu.upload_image_id , pu.case_info_id , pu.loss_item_id , pu.case_no , pu.upload_time , pu.user_code , pu.mobile , pu.oss_key , pu.license_no , pu.shot_time , pu.shot_latitude , pu.shot_longitude , pu.img_name , pu.img_path , pu.img_type , pu.lock_flag , pu.break_point_flag , pu.stay_upload , pu.remark , pu.create_by , pu.create_time , pu.modify_by , pu.modify_time from prpm_upload_image pu where pu.upload_image_id in ( select ir.upload_image_id from prpm_item_img_rela ir where ir.loss_item_id in ( :1 , :2 ) ) order by pu.shot_time asc 建议: 【 严重 】 该sql含有子查询,严重影响了查询性能,请改写sql,尝试去掉子查询,或者讲将查询改写为join。 SQL: select pu.upload_image_id , pu.case_info_id , pu.loss_item_id , pu.case_no , pu.upload_time , pu.user_code , pu.mobile , pu.oss_key , pu.license_no , pu.shot_time , pu.shot_latitude , pu.shot_longitude , pu.img_name , pu.img_path , pu.img_type , pu.lock_flag , pu.break_point_flag , pu.stay_upload , pu.remark , pu.create_by , pu.create_time , pu.modify_by , pu.modify_time from prpm_upload_image pu where pu.upload_image_id in ( select ir.upload_image_id from prpm_item_img_rela ir where ir.loss_item_id in ( :1 , null ) ) and pu.break_point_flag = :2 order by pu.shot_time asc 建议: 【 严重 】 该sql含有子查询,严重影响了查询性能,请改写sql,尝试去掉子查询,或者讲将查询改写为join。 SQL: select count ( * ) from prpm_case_info_cyp ci left join prpm_loss_item_cyp pl on ci.case_info_cyp_id = pl.case_info_cyp_id , prpm_survey_user cu , prpm_org com where cu.valid_status = :1 and cu.survey_user_code = pl.surveyor_code and cu.org_id = com.org_id and claim_status = :2 and loss_type = :3 and handle_status not in ( :4 , :5 ) and pl.auditor_code = :6 建议: 【 严重 】 扫描行与发送行的比是112488,并且使用了聚合函数,该SQL索引过滤性不好,影响服务器性能