Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Of course, it depends.</p> <p>It depends upon the work that the particular stored procedure performs and, perhaps, not so much the "read/write ratio" that you suggest. In general, you should consider enclosing a unit of work within a transaction if it is query that could be impacted by some other, simultaneously running query. If this sounds nondeterministic, it is. It is often difficult to predict under what circumstances a particular unit of work qualifies as a candidate for this.</p> <p>A good place to start is to review the precise <a href="http://en.wikipedia.org/wiki/Create,_read,_update_and_delete" rel="nofollow noreferrer">CRUD</a> being performed within the unit of work, in this case within your stored procedure, and decide if it a) could be affected by some other, simultaneous operation and b) if that other work matters to the end result of this work being performed (or, even, vice versa). If the answer is "Yes" to both of these then consider wrapping the unit of work within a transaction.</p> <p>What this is suggesting is that you can't always simply decide to either <em>use or not use transaction</em>s, rather you should apply them when it makes sense. Use the properties defined by <a href="http://en.wikipedia.org/wiki/ACID" rel="nofollow noreferrer">ACID</a> (Atomicity, Consistency, Isolation, and Durability) to help decide when this might be the case.</p> <p>One other thing to consider is that in some circumstances, particularly if the system must perform many operations in quick succession, e.g., a high-volume transaction processing application, you might need to weigh the relative performance cost of the transaction. Depending upon the size of the unit of work, a commit (or rollback) of a transaction can be resource expensive, perhaps negatively impacting the performance of your system unnecessarily or, at least, with limited benefit.</p> <p>Unfortunately, this is not an easy question to precisely answer: "It depends."</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload