locks and models

  • Hi,

    What is the difference between Pessimestic and optimistic locking models?

    how these realted to the avaliable locks in sql sever.

  • mroja_2005 (8/20/2009)


    Hi,

    What is the difference between Pessimestic and optimistic locking models?

    I'd used pessimistic and optimistic locks in the past in visual basic 6.0.

    In pessimistic lock, a particular user wont be able to modify the data which some other user is querying and he is done with updating and saving the affected records.

    In optimistic lock, the user will be able to modify the data which another user is querying.

    refer : http://www.wwwcoder.com/parentid/191/tabid/68/type/art/site/6508/default.aspx



    Pradeep Singh

  • The basic difference between Optimistic and Pessimistic locking is the time at which the lock on a

    row or page occurs. A Pessimistic lock is enforced when the row is being edited while an Optimistic

    lock occurs at the time the row is being updated. Obviously the time between an Edit and Update can

    be very short, but Pessimistic locking will allow the database provider to prevent a user from

    overwriting changes to a row by another user that occurred while he was updating it. There is no

    provision for this under Optimistic locking and the last user to perform the update wins.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply