delete from mss_emp_attendance where emp_id = #{employeeId} and check_date between to_date(#{month},'yyyy-MM-dd') and add_months(to_date(#{month},'yyyy-MM-dd'),1)+1
对比:
delete from mss_emp_attendance where emp_id = #{employee} and to_char(check_date,'yyyy-MM') = #{month}
如果因为数据量大对check_date创建了索引,这时候如果对check_date使用to_char(),to_date()函数将大大降低数据操作的效率,失去了创建索引的作用。