I have a map with huge amount of data being populated (around 300,000 records in approx)
and iterating it as below ,
for (Map.Entry&
Instead of updating the database in each loop.Try to update the database after completing the loop.
There are different way to optimize the large database update. Best one of that is
Also use a thread based queuing mechanism to send your emails