Update performance issue when performing many single update() operations
I'm having big performance issues trying to update many rows inside a transaction here's the code:
I tried to parallelise the updates with a Promise.all but no improvements.
I have about 50 elements in data and it takes an astonishing 4 seconds to do such a simple update.
Note: I cannot use the updateMany because I need to update each rows with specific data, I used
Total: 1234 here to simplify the example
5 Replies
You chose to debug with a human. They'll tinker with your query soon. If you get curious meanwhile, hop into
#ask-ai for a quick spin!I realized that I could use updateMany to nearly double the speed. Probably because there is no return of the entity after an updateMany
Any other improvements that can be done?
db calls in transactions run on a single connection
so
Promise.all() has no effectDid you see any improvements after using updateMany?
Absolutely, speed is twice faster now.