Optimistic concurrency control: Difference between revisions

Content deleted Content added
{{unsourced}}, rephrase, formatting, misc
fix list formatting with HTML
Line 7:
There are three phases in an OCC transaction:
 
<ol>
# '''Read''': The client reads values from the database, storing them to a private sandbox or cache that the client can then edit.
#<li>'''Read''': The client reads values from the database, storing them to a private sandbox or cache that the client can then edit.</li>
<li>'''Validate''': When the client has completed editing of the values in its sandbox or cache, it initiates the storage of the changes back to the database. During validation, an algorithm checks if the changes to the data would conflict with either
#* already-committed transactions in the case of ''backward validation schemes'', or
#* currently executing transactions in the case of ''forward validation schemes''.
#:If a conflict exists, a conflict resolution algorithm must be used to resolve the conflict somehow (ideally by minimizing the number of changes made by the user) or, as a last resort, the entire transaction can be aborted (resulting in the loss of all changes made by the user).
</li>
# <li>'''Write''': If there is no possibility of conflict, the transaction commits.</li>
</ol>
 
When conflicts are rare, validation can be done efficiently, leading to higher throughput than other concurrency control methods.{{fact}} However, if conflicts happen often, the cost of repeatedly restarting transactions, hurts performance significantly &mdash; other [[non-lock concurrency control]] methods have better performance when there are many conflicts.