MYSQL L Transaction ISOLATION Level

Source: Internet
Author: User

Several concepts related to the transaction isolation level:

Dirty read: Read data that has not yet been committed by another transaction
Non-repeatable READ: Read the data submitted by other things, the focus of non-repeatable reading is to modify (the other transaction modified this data), the same condition, you read the data, read it again to find the value is different
Phantom read: Read the new data inserted by other transactions (the focus of the Phantom reading is to add or delete) The same conditions, the 1th and 2nd read out the number of records are different


the separation capability of each separation level is as follows:
Read uncommited: Dirty read, non-repeatable read, Phantom read
Read commited: Non-repeatable read, Phantom read
REPEATABLE READ: Phantom read occurs
Serializable: These phenomena do not appear

READ UNCOMMITTED (Read UNCOMMITTED content)

At this isolation level, all transactions can see the execution results of other uncommitted transactions. This isolation level is rarely used in real-world applications because it has no better performance than other levels. Reading uncommitted data is also known as Dirty reading (Dirty read).

Read Committed (read submit content)

This is the default isolation level for most database systems (but not MySQL default). It satisfies the simple definition of isolation: A transaction can only see changes that have been submitted to the firm. This isolation level also supports non-repeatable reads (nonrepeatable read), because other instances of the same transaction may have new commits (new modifications) during the processing of the instance, so the same select may return different results.


Repeatable Read (can be reread)

This is the default transaction isolation level for MySQL, which ensures that multiple instances of the same transaction will see the same rows of data while concurrently reading the data. In theory, however, this can lead to another tricky problem: Phantom Reading (Phantom read). Phantom reading refers to when a user reads a range of data rows, another transaction inserts a new row within that range, and when the user reads the data row for that range again, a new row ( Phantom ) is found. The InnoDB and Falcon storage engines address this issue through a multi-version concurrency control (mvcc,multiversion Concurrency control) mechanism.

Serializable (Serializable)


This is the highest isolation level, which solves the Phantom reading problem by forcing transactions to sort, making it impossible to conflict with one another. In short, it adds a shared lock on each read row, and the subsequent transaction waits for the previous transaction to commit or rollback. At this level, a large number of timeouts and lock competitions can result.

MYSQL L Transaction Isolation level

Related Article

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.