implement UPSERT instead of DELETE+INSERT to reduce number of DB transactions