This is not my understanding of how anvils in_transaction
blocks work. As I understand it, really the only thing the in_transaction
block does is open and close a transaction for you as your function is entered/exited, such that if the function throws an error at any point the entire transaction is rolled back (so you don’t end up with partially committed changes). It also makes sure that multiple concurrent database calls that might affect the same rows will not overlap. However, it does NOT combine the database calls - so for example, multiple inserts will still be executed one after another, and not as a bulk insert.
Long story short - I wouldn’t expect the in_transaction
block to affect performance.