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
await prisma.$transaction(async (t) => {
const promises = data.map((d) => {
return prismaClient.myTable.update({
where: { ID: d.ID },
data: {
Total: 1234,
},
});
});
await Promise.all(promises);
});