Intro every day )
-
Pessimistic Locking: This approach involves locking data as soon as it is accessed, assuming that conflicts will likely occur. It prevents other transactions from accessing or modifying the same data until the lock is released, reducing the chance of conflicts but potentially leading to lower concurrency and performance.
-
Optimistic Locking: In contrast, this approach assumes that conflicts are rare, so it allows multiple transactions to access and modify the same data concurrently. Before committing changes, it checks if any other transactions have modified the data since it was last read. If conflicts are detected, it typically rolls back the transaction or takes appropriate action to resolve the conflict.
See