Junior — Middle
Can you explain what is meant by 'pessimistic transaction' in the context of database management systems?
sobes.tech AI
Answer from AI
A pessimistic transaction is an approach in database management systems where the transaction locks necessary resources (such as table rows) immediately at the start of working with them to avoid conflicts with other transactions.
The main idea is to assume that conflicts will occur and prevent them in advance by locking data until the transaction is completed. This guarantees data integrity but may reduce concurrency and performance due to waiting for locks.
Example: when updating a record, the transaction immediately places an exclusive lock on that record so that other transactions cannot modify it until the current transaction is finished.