Optimize delete and insert.