• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

optimistic and pessimistic concurrency control?

 
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Difference between optimistic and pessimistic concurrency control? can you tell me at what kind of senerio we use this ?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Optimistic concurrency control (or optimistic locking) is a technique used with relational databases whereby you use versioning to avoid lost updates. It works by adding some sort of version field to an entity. When your application selects a record from that table it notes the version, when you try to update the record you check the version to see if it is the same. If it isn't, you know that some other process has updated the record and the copy your application has is out of dat, so no update should take place. It is used so as to not require exclusive row locking everytime your application selects a record it them may update, and its called "optimistic" because it works on the assumption that most of the time there will be no conflicts.

Pessimistic concurrency control (or pessimistic locking) is where a row is exclusively locked for the entire duration it is in applciation memory. It is to be avoided, unless you have a good reason to need it, because becomes a bottleneck where more and more users are stuck waiting for locks to be released.
 
Aaron Raja
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul
 
Don't listen to Steve. Just read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic