I have a function where I have to process large amount of data, and some data may be repeated which needs to be updated. So I am looping through the data and updating if exists and if not inserting into the database. But the problem is that this is making my function running slower. So should I delete previous data and batch insert new data. Or should I continue to update existing data and inserting new data?