2016-12-16 阅读项目代码时,在项目的xml文件中发现如下写法: SELECT student_user_id FROM tbr_student_class WHERE 1=1 <if test="@Ognl@isNotEmpty(classId)"> and class_id =#{classId} </if> <if test="@Ognl@isNotEmpty(stuId)"> and student_user_id
order表: order type gmt_create type 取值: 0,1 其中0非常多,1非常少. 当查询条件里 select * from order where type=0 and gmt_create > '2017' limit 20; 由于海量数据,可能搜索1千 w 才能得到1个数据. 所以要得到20个可能就要 mysql 遍历完一个亿的数据. 这时候就要考虑如何用索引,一步步的查询. 一个方案是将原表分表. 根据 type 先分表. 直接分成两张表,而不是多加一个