Don't optimize immediately after deleting records; instead optimize at end of batch processing.