分区表批量删除数据出现异常,出现删不掉的假象
关于分区表数据删除,之前删除的时候一直根据主键删除,但是之后发现有时候删除没有结果返回
<delete id="del_road_bill_info"> delete from road_bill_info_table where ele_bill_id in <foreach collection="list" item="item" open="(" separator="," close=")">#{item,jdbcType=VARCHAR}</foreach></delete>
后来发现由于该表是分区表的缘故,有时候删除数据执行时间比较长,虽然最终能删除数据,但是严重影响用户体验
故,删除分区表的时候需要加上分区条件。
<delete id="del_road_bill_info"> delete from road_bill_info_table where ele_bill_id in <foreach collection="ids" item="item" open="(" separator="," close=")">#{item,jdbcType=VARCHAR}</foreach> and run_date between p_time_patition.givenStartTime(#{runDate,jdbcType=VARCHAR}) and p_time_patition.givenEndTime(#{runDate,jdbcType=VARCHAR}) </delete>