mysql 创建的优化就是加索引,可是有时候会遇到加索引都没法达到想要的效果的情况,
加上了所以,却还是搜索的全数据,原因是sql
EXPLAIN SELECT cs.sid, -- c.courseFrontTitle, -- c.imgBig, cs.studyStatus, coi.fee, -- act.PROC_INST_ID_ AS processId, cs.createDTM, cs.payStatus, cs.isCompleted, cs.saleChannel, cs.isDelete FROM Biz_CourseStudy cs LEFT JOIN Biz_CourseOrderItem coi ON cs.sid = coi.CourseStudyID WHERE cs.studentID = 00001 and cs.payStatus not in(0)
通过看索引,原因是因为sid为bigint , CourseStudyID 的类型确实varchar,原因就是在这里,修改类型为bigint后,查询速度瞬间提升.