Understanding the Isolation Property in a Database

Isolation controls how and when changes are made in a database

Isolation is the database-level property that controls how and when changes are made, and if they become visible to each other, users, and systems. One of the goals of isolation is to allow multiple transactions to occur at the same time without adversely affecting the execution of each.

Isolation is an integral part of database transactional properties. It is the third property of the ACID (Atomicity, Consistency, Isolation, Durability) standards that ensure data remains consistent and accurate.

How Isolation Works

If Joe issues a database transaction at the same time that Mary issues a different transaction, both transactions should operate on the database in an isolated manner. The database should either perform Joe's entire transaction before executing Mary's or vice-versa.

This exclusivity prevents Joe's transaction from reading intermediate data produced as a side effect of part of Mary's transaction that will not eventually be committed to the database.

The isolation property does not ensure that a specific transaction will execute first, only that they will not interfere with each other.

Isolation Levels

There are four levels of isolation. Higher isolation limits the ability of users to concurrently access the same data. The higher the isolation level, the greater system resources are required and the more likely database transactions will block one another.

  • Serializable is the highest level, which means that one transaction must complete before another transaction can start.
  • Repeatable reads allow transactions to be accessed once the transaction has started, even if it hasn't finished. This level allows for phantom reads, or awareness of inserted or deleted rows even if changes to existing rows aren't readable.
  • Read committed allows the data to be accessed after the data has been committed to the database, but not before then.
  • Read uncommitted is the lowest level of isolation and allows data to be accessed before the changes have been made. 

As the isolation level is lowered, the more there is a chance that users will encounter read phenomena such as uncommitted dependencies, also known as dirty reads, which result in data being read from a row that has been modified by another user but not yet committed to the database.

Was this page helpful?