Using TypeORM to perform two operations in a single transaction with no specified order. Will utilizing Promise.all result in faster processing, or do the commands wait internally regardless?
Is there any discernible difference in efficiency between the two options?
// Option 1
getManager().transaction(async manager => {
await Promise.all([
manager.insert(...),
manager.update(...),
]);
});;
// Option 2
getManager().transaction(async manager => {
await manager.insert(...);
await manager.update(...);
});
To clarify, I am aware of how Promise.all
can enhance performance in JavaScript overall due to its single-threaded nature and event loop mechanics. However, my inquiry pertains specifically to the behavior of multiple queries within the same transactional manager in TypeORM, as they appear to execute sequentially whether Promise.all
is used or not.