Question
What is the advantage of optimistic concurrency control compared with pessimistic concurrency control?
Answer
What is concurrency control?
Concurrency control is a process used to manage transactions in a shared database at the same time. It ensures the processing of transactions that occur in the database. Controls the database when multiple transactions happen in the database. There are two types of concurrency control, as follows:
1. Optimistic concurrency control
Optimistic concurrency control is also called optimistic locking. When two users try to access the same record, it will lock the records of all users except the first user.
2. Pessimistic concurrency control
Pessimistic concurrency control is also called a pessimistic lock, which locks the records for all users when the two users try to access the same record.
Advantages of Optimistic Concurrency over Pessimistic Concurrency are as given below:
Compared with pessimistic concurrency control, optimistic concurrency control has less overhead. Optimistic concurrency control is functional when the chance or occurrence of conflict is very low. A gloomy system assumes the worst. You think that two or more users will want to update the same record simultaneously and then lock the record to avoid this possibility, no matter how likely the conflict is.
إرسال تعليق