<p>From <a href="https://stackoverflow.com/questions/60419/do-i-really-need-to-use-transactions-in-stored-procedures-mssql-2005">this post</a>. One obvious problem is scalability/performance. What are the other problems that transactions use will provoke?</p>

<p>Could you say there are two sets of problems, one for long running transactions and one for short running ones? If yes, how would you define them?</p>

<p>EDIT: Deadlock is another problem, but data inconsistency might be worse, depending on the application domain. Assuming a transaction-worthy domain (banking, to use the canonical example), deadlock possibility is more like a cost to pay for ensuring data consistency, rather than a problem with transactions use, or you would disagree? If so, what other solutions would you use to ensure data consistency which are deadlock free? </p>

[{'answer_id': 60521, 'author': 'Adam Davis', 'author_id': 2915, 'author_profile': 'https://Stackoverflow.com/users/2915', 'pm_score': 1, 'selected': False, 'text': "<p>One issue with transactions is that it's possible (unlikely, but possible) to get deadlocks in the DB.  You do have to understand how your database works, locks, transacts, etc in order to debug these interesting/frustrating problems.</p>\n\n<p>-Adam</p>\n"}, {'answer_id': 60526, 'author': 'Ash', 'author_id': 5023, 'author_profile': 'https://Stackoverflow.com/users/5023', 'pm_score': 0, 'selected': False, 'text': '<p>I think the major issue is at the design level.  At what level or levels within my application do I utilise transactions.</p>\n\n<p>For example I could:</p>\n\n<ul>\n<li>Create transactions within stored procedures, </li>\n<li>Use the data access API (ADO.NET) to control transactions </li>\n<li>Use some form of implicit rollback higher in the application</li>\n<li>A distributed transaction in (via DTC / COM+).</li>\n</ul>\n\n<p>Using more then one of these levels in the same application often seems to create performance and/or data integrity issues.</p>\n'}, {'answer_id': 60528, 'author': 'Curt Hagenlocher', 'author_id': 533, 'author_profile': 'https://Stackoverflow.com/users/533', 'pm_score': 2, 'selected': False, 'text': '<p>You can get deadlocks even without using explicit transactions.  For one thing, most relational databases will apply an implicit transaction to each statement you execute.</p>\n\n<p>Deadlocks are fundamentally caused by acquiring multiple locks, and any activity that involves acquiring more than one lock can deadlock with any other activity that involves acquiring at least two of the same locks as the first activity.  In a database transaction, some of the acquired locks may be held longer than they would otherwise be held -- to the end of the transaction, in fact.  The longer locks are held, the greater the chance for a deadlock.  This is why a longer-running transaction has a greater chance of deadlock than a shorter one.</p>\n'}, {'answer_id': 256843, 'author': 'MarkR', 'author_id': 13724, 'author_profile': 'https://Stackoverflow.com/users/13724', 'pm_score': 3, 'selected': True, 'text': '<p>It depends a lot on the transactional implementation inside your database and may also depend on the transaction isolation level you use. I\'m assuming "repeatable read" or higher here. Holding transactions open for a long time (even ones which haven\'t modified anything) forces the database to hold on to deleted or updated rows of frequently-changing tables (just in case you decide to read them) which could otherwise be thrown away. </p>\n\n<p>Also, rolling back transactions can be really expensive. I know that in MySQL\'s InnoDB engine, rolling back a big transaction can take FAR longer than committing it (we\'ve seen a rollback take 30 minutes).</p>\n\n<p>Another problem is to do with database connection state. In a distributed, fault-tolerant application, you can\'t ever really know what state a database connection is in. Stateful database connections can\'t be maintained easily as they could fail at any moment (the application needs to remember what it was in the middle of doing it and redo it). Stateless ones can just be reconnected and have the (atomic) command re-issued without (in most cases) breaking state.</p>\n'}]
['https://Stackoverflow.com/questions/60518', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5190/']