Analyze and optimize concurrency

Completed

Concurrency is used to control when data is available for other processes. finance and operations apps uses two concurrency models:

  • Pessimistic Concurrency Control (PCC) - Locks records as soon as they are retrieved from the database.
  • Optimistic Concurrency Control (OCC) - Locks records when they are being updated.

The PCC model should be used when there is serialization logic that requires locks on the record, or when update conflicts are likely.

OCC should be used on tables where it improves throughput in contrast to PCC. Also, OCC is preferred if the table is updated or deleted from a form and not from code.

OCC has advantages that help increase database performance:

  • Fewer resources are used to lock records during updates.
  • Records are locked for a shorter length of time by using OCC instead of PCC.
  • Records remain available for other processes while they are selected from the database.

The disadvantage of using OCC happens when two processes try to update the same record at the same time. When this occurs, the update will fail, which can lead to reduced database performance if there are multiple retries to updates.

All standard tables in finance and operations apps have a concurrency model selected, and most of the tables use OCC. You can set the concurrency model on the OccEnabled table property. Additionally, you can override the table concurrency model in a Select statement. After the keyword Select, you can use the keyword optimisticLock or pessimisticLock to replace the keyword forUpdate.

Screenshot of the Properties page, highlighting the Concurrency model dropdown menu.