Isolation level read consistency for relational databases

Source: Internet
Author: User
Tags serialization

From the network:

Three types of preventable phenomena:

Dirty Reads (dirty Read): Transactions can read modifications that have not yet been committed by other transactions;

Non-repeatable read (Nonrepeatable Read): The transaction reads data that has been read previously and discovers that other committed transactions have modified or deleted the data to be read;

Phantom Read (Phantom Read): The transaction executes a query again, discovering that other committed transactions have inserted new data that satisfies the current query criteria.

According to the above three phenomena, the SQL92 standard specifies 4 kinds of isolation system, the 4 kind of isolation system is more strict than one.

READ UNCOMMITTED: Allow dirty reads, non-repeatable reads, and Phantom reads;

Read Committed: Do not allow dirty reads, allow non-repeatable reads and Phantom reads;

REPEATABLE READ: Do not allow dirty read, non-repeatable read, allow Phantom Read;

Serializable: Dirty reads, non-repeatable reads, and Phantom reads are not allowed.

Oracle offers read committed and serializable isolation levels, as well as an additional read-only mode. Read Committed mode is used by default.

Oracle Transaction ISOLATION LEVEL

Oracle supports the following three types of transaction isolation levels (transaction isolation level).

Isolation level Describe
Read Committed The transaction isolation level used by Oracle by default. Queries executed within a transaction can only see data that has been committed before the query executes (not before the transaction begins). Oracle's queries never read dirty data (uncommitted data).

Oracle does not prevent one transaction from modifying the data that is being accessed by a query in another transaction, so the data may be modified by other transactions during the execution interval of two queries within a transaction. For example, if the same query executes two times within a transaction, you may experience non-repeatable reads or no read.
 
Serialization Serialized isolated transactions can only see data that has been committed before the transaction executes, as well as inserts, UPDATE, and DELETE statements in the transaction. Serialized isolated transactions do not appear to be non-repeatable or read-only.
 
Read-only mode A read-only transaction can see only data that has been committed before the transaction executes, and the INSERT, UPDATE, and DELETE statements cannot be executed in the transaction.

My understanding:

The default isolation level for Oracle can only guarantee read consistency at the statement level, and if the transaction is executed halfway, other transactions are committed, and this effect is reflected in the query down the transaction.

The serial isolation level of Oracle guarantees read consistency at the transaction level, and during the entire transaction, only the state of the point at which the transaction begins to execute and the impact of the transaction during execution, and other transactions are not visible even if they are committed.

There are articles on the web saying that the serialization of transactions should be used in what scenario, the following excerpt:

Systems that meet the following characteristics are suitable for use with serialization isolation (serializable isolation):

1, the data volume is large, but the transaction is short, only will update the database with less data rows

2, two concurrent transactions the probability of modifying the same data is small

3. A transaction with a relatively long run time only performs read-only operations

This paragraph I see not quite understand, one is the transaction level of the read consistency, one is the sentence level of read consistency, suitable for what kind of scene, should be to see the severity of the business scenario it.

Later, when I looked through the Oracle concept book, I found out that it was from there. Since it is the Oracle's official website manual, it should be instructive. Perhaps Oracle's starting point is to compare the differences between the Read Committed isolation level and the serial isolation level. Because the serial isolation level is exclusive to the update operation of the data, it cannot be too many update operations or time-consuming updates to avoid conflicts with other transactions, causing too much waiting and impacting performance. Or because an exclusive transaction does not recognize an update commit operation for another transaction, ORA-08177: Unable to serialize access error.

Isolation level read consistency for relational databases

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.