BEGIN
 DECLARE del_count  INT;

 SET del_count = 1;

 WHILE del_count > 0 DO

        DELETE FROM te3logex1.db_instance_restart_time
        WHERE last_update_time <= (now() - interval day_back day)
        LIMIT 5000;

        SET del_count = (SELECT ROW_COUNT());

        COMMIT;
 END WHILE;

 END