ways to improve the performance of this scenario

前端 未结 6 1055
闹比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:13

    I'll try to summarize all good points mentioned above.

    Your options are,

    1. Use multithreading wherever possible but keep it mind that multithreading comes with a cost of additional memory(heapdumps and application will be down).
    2. Another good option is use bulk update but again bulk update comes with cost of more lock time at database end. so use it wisely as threads will be waiting till one thread finishes with updating as update will take exclusive lock i.e. no sharing possible.

    3. Try threading in along with async jobs (specially for mails) try to use different server/process for mail handling and send mail requests to mail server asynchronously which is quite fast as your mail generation task is handled by other process (In real life mail exchange can accept some delay thus your slow mail server is allowed but application server is not.)

    4. If possible move your complete Db update logic in stored procedure on DB server which will save your lot of time (Rule of Thumb : Always let A handle tasks for which A is designed/optimized i.e. DB are designed for faster DB operations than pgming languages.)

    Couldn't give you answer specific to your need but I hope this was helpful in terms of improving it :)

提交回复
热议问题