We know that there are some scenario开发者_如何学Cs that require us to implement transactions in code, such as SqlTransaction
/TransactionScope
in .Net framework. The questions are:
- What are the overheads (besides speed)?
- Does it gets worse if we add more layers between the transaction and the DB? If yes, then what are the overheads and what cause these overheads?
We want to keep transactions short, to begin them as late as possible and to end them as early as possible. Otherwise concurrency hurts, and we are getting more lock waiting and deadlocks.
Long running transaction can also cause transaction log to fill.
Adding more layers between transaction and DB itself doesn't add overhead on the transaction but it will increase the probability of something going wrong and leaving transaction uncommitted and long running transaction.
精彩评论