ways to improve the performance of this scenario

前端 未结 6 1032
闹比i
闹比i 2021-01-23 05:45

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&         


        
6条回答
  •  青春惊慌失措
    2021-01-23 06:31

    I would make something like this. Prepare the data for the operation.

    I suppose you are updating a table like user which should have a unique Id.

    Map emailIds = new HashMap();
    Map emails = new HashMap();
    for (Map.Entry> entry : testMap.entrySet()) {
     -- DONOT DO THIS// send email with map keys as email'id
     -- DONOT DO THIS// email content is populated from the list
     -- DONOT DO THIS// Perform a sql update to the column with the dyanamic value generated here with the email'id
    emails.put(emailId, content);
    emailIds.put(id, emailId);
    
    }
    
    bulkEmailSend(emails);
    bulkEmailUpdate(emailIds);
    

    bulkEmailSend and bulkEmailUpdate are the methods which should be written to make the appropriate calls.

    So, use the bulk email send and bulk emailId update methods to update the values back to the database.

提交回复
热议问题