Topic > SQL Transactions

The isolation level controls the extent to which a given transaction is exposed to the actions of other transactions running at the same time. By choosing one of four possible isolation level settings, a user can gain greater concurrency at the cost of increasing the transaction's exposure to uncommitted changes from other transactions. The effect of these levels is summarized. The greatest degree of isolation from the effects of other transactions is achieved by setting the isolation level for a transaction T to SERIALIZABLE. This level of isolation ensures that T reads only changes made by committed transactions, that no value read or written by T is modified by any other transaction until T completes, and that if T reads a set of values ​​based on some search, this set is not modified by other transactions until T completes (i.e., T avoids ghosting). In terms of a lock-based implementation, a SERIALIZABLE transaction obtains locks before reading or writing objects, including locks on sets of objects that it requires to remain unchanged (see Section 17.5.1), and holds them until the end, according to Strict 2PL. Say no to plagiarism. Get a tailor-made essay on "Why Violent Video Games Shouldn't Be Banned"? Get Original EssayEnsures that T only reads changes made by committed transactions, and that no values ​​read or written by T are modified by any other transactions until T completes. However, T may experience the phantom phenomenon; for example, while T examines all Sailors records with rating=1, another transaction might add a new Sailors record, which is missed by T. Ttransaction sets the same blocks as a SERIALIZABLE transaction, except that it does not execute the index lock; that is, it only locks individual objects and not sets of objects. It ensures that T only reads changes made by committed transactions, and that no value written by T is modified by any other transaction until T completes. However, a value read by T might be modified by another transaction while T is still in progress. course and T is exposed to the phantom problem. The transaction obtains exclusive locks before writing the objects and holds these locks until the end. It also gets shared locks before reading objects, but these locks are released immediately; their only effect is to ensure that the last transaction that modified the object is complete. (This guarantee is based on the fact that each SQL transaction obtains exclusive locks before writing objects and holds exclusive locks until the end.) Transaction T can read changes made to an object by an ongoing transaction; of course, the object can be modified further while T is in progress, and T is also vulnerable to the ghost problem. Ttransaction does not obtain shared locks before reading objects. This mode represents the greatest exposure to uncommitted changes to other transactions; to the point that SQL prohibits such a transaction from making changes on its own: a READ UNCOMMITTED transaction is needed to have a READ ONLY access mode. Since such a transaction gets no locks for reading objects and is not allowed to write objects (and therefore never requests exclusive locks), it never makes any lock requests. The isolation level is generally the most secure and is recommended for most transactions. Some transactions, however, can run at a lower level of isolation, and the fewer blocks required can help improve system performance. For example, a statistical query that.