Wednesday 18 December 2013

OCC vs PCC in Queries in ax 4.0

The concurrency model in Dynamics AX controls how records are locked when a select forupdate is executed.
Pesimistic Concurrency Control (PCC)
Optimistic Concurrency Control (OCC)
Dynamics AX 3.0 supports only the pessimistic concurreny model in that a select forupdate results in a SQL statement which aquires an update lock.

This will cause all selected rows to be readable but you can't update them or aquire any new update lock anymore. The update lock is held until the transaction is commit.
Dynamics AX 4.0 supports and primarily uses theoptimistic concurrency model in that a select forupdateresults in a SQL statement with no lock.

Here all selected rows can be read and updateded besides the rows that were updated already. In order to detect an update conflicts the RecVersion field is checked by the Dynamics AX Kernel.
while select forupdate custTable
   // SELECT ... WITH (UPDLOCK)
while select forupdate custTable
   // SELECT ... WITH (NOLOCK)
In both concurrency models the exclusive locking time is the same. The below table visualizes this.

No comments:

Post a Comment