Using an asynchronous transaction in a transaction

We are currently using dapper to handle very expensive update / deletion scripts, and we are very pleased with that.

Now we have the following scenario that I want to speed up.

  • Update 1 takes about 60 seconds.
  • Update 2 takes less than 1 second.

If we do this as synchronization, we will spend a total of about 61 seconds. Can we speed this up to trigger the first update using the method ExecuteAsync, but don't expect it. For instance:

Connection.ExecuteAsync("Update 1", new { someValue }, Transaction, 120);
Connection.Execute("Update 2", new { someValue }, Transaction);

Note the lack of a keyword await.

This will speed up the process, but it's a good idea, and will it work in a transaction? What happens when a transaction commit is committed and the first update is still in progress? Or is it a bad idea to use ExecuteAsync without waiting?

Assuming Update 2 is independent of Update 1.

+4
source share
1 answer

If the first update does not work in the same data of the second, and you do not need to wait for the result, you can execute it in async mode without waiting. I suggest you read this page:

http://www.joesauve.com/async-dapper-and-async-sql-connection-management/

, async , , .

0

Source: https://habr.com/ru/post/1569704/


All Articles