Wednesday, April 16, 2014

The Difference between Optimistic concurrency control(OCC) and Pessimistic concurrency control(PCC).



  1. Optimistic concurrency control (OCC) helps increase the database performance.
  2.  Optimistic concurrency control locks records only from the time the real update operation is started (i.e. during update process). So, the records are locked for a shorter duration of time and will be available for other process (for update process).
  3.  OCC makes it possible for other processes to update the record even after the record is fetched. Here the disadvantage is if another process updates the same records which are fetched, then the update fails and retry will take more time which hits the performance.
  4. In OCC fewer resources are being used to hold the locks during the update process.
  5. Property used on table is OccEnabled. Defaulted to Yes.
  • Pessimistic concurrency control locks the records immediately after they are fetched from the database for update.
  • To set concurrency model for a select statement, just replace forupdate with the optimistic or pessimistic as shown below.
For Example:-      Select optimistic CustTable
                            Select pessimistic CustTable.





No comments:

Post a Comment