Transactions four isolation Levels

Source: Internet
Author: User

2. transactions four isolation levels

1. If two threads are modified concurrently, They will be disruptive to each other , and the lock mechanism must be used to prevent concurrent modification of multiple threads.

2. If two threads are queried concurrently , There is no thread safety issue

3. If two threads a modification , a query ... will have 3 Types of questions:

1). Dirty reads : One transaction reads to another transaction UNCOMMITTED Data

     2). non-repeatable read : --- Row-level issues (change)

3). Virtual Read ( Phantom Read ): refers to a transaction that reads a different transaction the inserted data , causing inconsistencies in the read and backward reading --- table-level issues (additions and deletions)


Four isolation levels :

do not prevent any isolation problems dirty read / non-repeatability / ( Phantom read ) question

can prevent dirty reading problems Span style= "FONT-FAMILY:CALIBRI;" >/ virtual read ( Phantom read ) question

REPEATABLE READ- prevents dirty reads / non-repeatable read problems , but does not prevent virtual reads ( Phantom reads ) Problem

Serializable- database is designed as a single-threaded database to prevent all of the above issues

from the security considerations : serializable>repeatable read>read Committed>read Uncommitted

consider in terms of efficiency : Read Uncommitted>read committed>repeatable read>serializable

When real data is used , based on the needs of your own database , comprehensive analysis of security and efficiency requirements , Select an isolation level to run the database at this isolation level .

MySQL By default is the repeatable read isolation level

Oracle By default is the Read Committed isolation level

Query the isolation level of the current database : SELECT @ @tx_isolation;

set Isolation Levels : Set [global/session] transaction isolation level xxxx; where if you do not write the default is Session refers to the isolation level when modifying the current client and database interactions , and if you use Golbal, The default isolation level for the database is modified .

locking mechanism in the database ---- Shared Locks , Exclusive Lock :

in thenon- Serializable Isolation LeveldoEnquirywithout any locks ., while under the Serializable isolation level. EnquiryPlusShared Locks. features : shared and shared locks can coexist , but shared and exclusive locks cannot coexist

at all isolation levels Delete and change The operation will be added Exclusive Lock . features : cannot coexist with any other lock


Transactions four isolation Levels

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.