Site icon TechTricky: A Technology Blog on HTML, CSS, JQuery, Webaps and How to\'s

DB2 Isolation Levels

DB2 Isolation Levels: How Isolation Levels are useful, what are the different Isolation Level types(CS, RR, RS & UR), how it controls the concurrency, What is Concurrency?,  which one is better to use among the four types? What are the advantages and disadvantages ?These are the questions we often encounter. So this topic explains these queries in detail.

In DB2 or in any Relational databases, the concurrency & data integrity is the key factor. Concurrency is the feature that makes multiple applications or users to access the resources at the same time without affecting each other’s work. Concurrency control is important as without the proper concurrency the applications may end with an invalid data access.

Isolation level parameter is one of the BIND parameters which plays a major role in the concurrency control. Basically it decides how the other applications are isolated from a data base object which is being accessed by one application. It decides when to acquire the locks and when to release the acquired locks.
DB2 supports page & row level locking at the program execution level, which means isolation level applies the row and/or page level locking. One thing to be noted is, regardless of the Isolation Level used database Manager applies the Exclusive locks on the rows that are being updated by any application.

Isolation level parameter decides:

By setting the proper Isolation Level, the transactions can be isolated to achieve a good concurrency.

There are 4 types of isolation levels that can be applied

Cursor Stability (CS):

This is the most commonly used isolation levels among the 4 isolation levels and it is the default isolation level. CS locks the row that is being accessed and lock gets released once the cursor has moved from that row. So this isolation level gives more concurrency by locking only the row that is currently being accessed.

Notes:

Repeatable Read (RR):

Repeatable read isolation level gives the highest level of data integrity which does not allow other applications to access the rows that is being scanned by one application.
For example if one transaction is trying to select 10 rows but in the process it has to scan 100 rows, then it applies locks on the whole 100 rows. In this if the first transaction fires the same query then the same number of rows will be retrieved.

Notes:

Read Stability (RS):

Read stability is same as the repeatable read isolation level except it locks only the rows which are being accessed by that particular transaction. Unlike the RR it does not lock all the rows which are scanned.

Notes:

Uncommitted read (UR):

Uncommitted read gives the lowest level of integrity as it does not apply any locks on the data that is being accessed. As name suggests it also accesses the rows which are not committed by other transactions/applications, so it also called as ‘Dirty reads€™.

Notes:

Exit mobile version
Close Bitnami banner
Bitnami