What are the advantages of multiple transactions that are allowed to run concurrently in the system?
A transaction is a unit of database processing which contains a set of operations. For example, deposit of money, balance enquiry, reservation of tickets etc. Show
Every transaction starts with delimiters begin transaction and terminates with end transaction delimiters. The set of operations within these two delimiters constitute one transaction. main() { begin transaction } end transaction There are three possible ways in which a transaction can be executed. These are as follows −
Concurrent transaction or execution includes multiple transactions which are executed concurrently or simultaneously in the system. AdvantagesThe advantages of the concurrent transactions are as follows −
ExampleT1= 90sec T2= 500sec T3= 5sec. If we execute serially by T1->T2->T3 then transaction T3 waits for 590 sec, so we go for non-serial or concurrent transactions to reduce waiting time. i.e. T3 -> T1 -> T2. DisadvantageThe disadvantage is that the execution of concurrent transactions may result in inconsistency. Example 1The concurrent execution given below is in a consistent state. Example 2The transaction given below is not consistent. Concurrent schedules do not keep the database in the consistent state. The concurrent execution of the transactions has to be carried out in a controlled environment. If a system consists of ‘n’ number of transactions, we will have more than ‘n!’ number of concurrent schedules, out of which only a few of them are keeping the database in consistent state.
Updated on 06-Jul-2021 14:47:29
Concurrency Control deals with interleaved execution of more than one transaction. In the next article, we will see what is serializability and how to find whether a schedule is serializable or not. What is Transaction? A set of logically related operations is known as a transaction. The main operations of a transaction are: Read(A): Read operations Read(A) or R(A) reads the value of A from the database and stores it in a buffer in the main memory. Write (A): Write operation Write(A) or W(A) writes the value back to the database from the buffer. (Note: It doesn’t always need to write it to a database back it just writes the changes to buffer this is the reason where dirty read comes into the picture) Let us take a debit transaction from an account that consists of the following operations:
Assume A’s value before starting the transaction is 5000.
But it may also be possible that the transaction may fail after executing some of its operations. The failure can be because of hardware, software or power, etc. For example, if the debit transaction discussed above fails after executing operation 2, the value of A will remain 5000 in the database which is not acceptable by the bank. To avoid this, Database has two important operations: Commit: After all instructions of a transaction are successfully executed, the changes made by a transaction are made permanent in the database. Rollback: If a transaction is not able to execute all operations successfully, all the changes made by a transaction are undone. Properties of a transaction:Atomicity: As a transaction is a set of logically related operations, either all of them should be executed or none. A debit transaction discussed above should either execute all three operations or none. If the debit transaction fails after executing operations 1 and 2 then its new value of 4000 will not be updated in the database which leads to inconsistency. Consistency: If operations of debit and credit transactions on the same account are executed concurrently, it may leave the database in an inconsistent state.
Table 1 Isolation: The result of a transaction should not be visible to others before the transaction is committed. For example, let us assume that A’s balance is Rs. 5000 and T1 debits Rs. 1000 from A. A’s new balance will be 4000. If T2 credits Rs. 500 to A’s new balance, A will become 4500, and after this T1 fails. Then we have to roll back T2 as well because it is using the value produced by T1. So transaction results are not made visible to other transactions before it commits. Durable: Once the database has committed a transaction, the changes made by the transaction should be permanent. e.g.; If a person has credited $500000 to his account, the bank can’t say that the update has been lost. To avoid this problem, multiple copies of the database are stored at different locations. What is a Schedule? A schedule is a series of operations from one or more transactions. A schedule can be of two types:
Question: Consider the following transaction involving two bank accounts x and y:
The constraint that the sum of the accounts x and y should remain constant is that of?
Solution: As discussed in properties of transactions, consistency properties say that sum of accounts x and y should remain constant before starting and after completion of a transaction. So, the correct answer is B. Advantages of Concurrency:In general, concurrency means, that more than one transaction can work on a system. The advantages of a concurrent system are:
Next article- Serializability of Schedules Article contributed by Sonal Tuteja. Please write comments if you find anything incorrect, or if you want to share more information about the topic discussed above. What are the advantages of concurrently running transactions?Advantages of concurrency
Reduced waiting time response time or turn around time. If we run only one transaction at a time than the acid property is sufficient but it is possible that when multiple transactions are executed concurrently than database may become inconsistent.
What are the benefits and challenges of concurrent transactions?Author: krishnabhatia. advantages are- ... . Concurrency gives the following two advantages. ... . Using Concurrency, many Transactions executes simultaneously due to which waiting time decreases and also increase in resource utilization. ... . By having concurrency control you avoid dirty writes (or inconsistent data).. What are the advantages of concurrent execution over serial execution?Reduced waiting time:
If the transactions are operating on different parts of the database, it is better to let them run concurrently, sharing the CPU cycles and disk accesses among them. Concurrent execution reduces the unpredictable delays in running transactions.
What is the main goal of allowing concurrent execution of transactions?This property of DBMS allows many transactions to access the same database at the same time without interfering with each other. The primary goal of concurrency is to ensure the atomicity of the execution of transactions in a multi-user database environment.
|