Isolating database transactions

Application's ability to show the consistent data is based on the isolation level of a transaction.
Based on the level chosen,  you can get that degree of isolation for a database transaction from other concurent transactions. 

Below are the isolation levels supported by resource local transactions. 

ISOLATION LEVELS (More generic to More specific)
----------------
READ UNCOMMITTED 
READ COMMITTED  - Protects against dirty reads.
REPEATABLE READ - Protects against dirty and non-repeatable reads.
SERIALIZABLE  - Protects against dirty, non-repeatable and phantom reads

Dirty Read - Reading uncommitted Data

Non-Repeatable Read - Data is not the same for 2 different reads.
Reason: some other user runs a transaction and committed it.

Phantom Read - Though Data is same for 2 different reads in the same transaction. Fresh rows area added  or deleted. Phantom read will have impact while using range conditions('>' or '<' or 'between') 
or aggregate functions(sum or group)

Cost of high isolation:
READ COMMITTED is the default isolation used by the databases. however, this value can be changed based on the  application requirements. But, as we increase the level of isolation, the level of concurrency (max no. of parallel transactions/sec) will reduce since, DB applies locks to isolate the data from other transactions

Comments

Popular posts from this blog

Distributed database design using CAP theorem

SQL Analytical Functions - Partition by (to split resultset into groups)

Easy approach to work with files in Java - Java NIO(New input output)