Optimistic concurrency control: Difference between revisions

Content deleted Content added
fix list formatting with HTML
SmackBot (talk | contribs)
m Date/fix maintenance tags
Line 1:
{{Unreferenced|date=February 2007}}
{{unsourced}}
 
In [[computer science]], in the field of [[database]]s, '''optimistic concurrency control''', (OCC) is a [[concurrency control]] method used in [[relational database]]s without using [[Lock (computer science)|lock]]ing. It is commonly referred to as '''optimistic locking''', a misnomer.
Line 17:
</ol>
 
When conflicts are rare, validation can be done efficiently, leading to higher throughput than other concurrency control methods.{{factFact|date=February 2007}} 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.
 
==Web usage==
 
The [[Stateless server|stateless]] nature of [[HTTP]] makes locking infeasible for web user interfaces.{{factFact|date=February 2007}} It's common for a user to start editing a record, then leave without following a "cancel" or "logout" link. If locking is used, other users who attempt to edit the same record must wait until the first user's lock expires.
 
OCC is a natural choice. It is simple to implement and avoids unnecessary waiting or silently overwritten records. Typically the [[Form (web)|form]] presented to the user includes a hidden field with the record's original content, a timestamp, a sequence number, or an opaque token. On submit, this is compared against the database. If it differs, the conflict resolution algorithm is invoked.