The understanding of the level of database transaction isolation in the interview ___ database
Source: Internet
Author: User
The so-called database isolation level is a conflict problem in order to resolve two or more transactions that operate on the same database object. The operation of the data is nothing more than read and write, and the transaction isolation level is primarily isolated between read and write transactions.
First, make a list of 4 isolation levels:
1.read uncommited (Readable uncommitted)
2.read commited (submitted in order to read)
3.repeatable Read (repeatable)
4.serializable (serialized read and write)
Let's start with a simple talk. Serializable is nothing but the strictest, no official you are read or write, must queue one by one, so this isolation level will not appear dirty reading and other problems, each transaction operation is completely belong to their own data, there will be no other business and you earn. But it is conceivable that this level is also the least efficient, and few scenarios use this isolation level.
Read uncommited reads the uncommitted data, which is what I read when I wrote it, and I wrote what you read in the database, but the transaction was not submitted, so you read dirty data. The first version of the database uses this transaction isolation level by default.
Read commited than read uncommit level a bit higher, I write, you can not read, only I submitted you can read, this level in favor of writing, can be understood to write a higher status, read all of the back row. This avoids the problem of dirty reading, but there is a situation where I need to read the database two times, the first time I read the data, well, this time you start to write the business, because you are high I will wait for you to finish reading, this can be imagined that the data was changed, in the reading and the first reading of the data is not the same, this is called Phantom Reading.
Phantom reading is two times read inconsistent data, and dirty reading is the same. But unlike dirty reads, dirty reads read data that writes transactions that have not yet been committed, while Phantom reads write transactions that have submitted data. It was just a two-time reading of inconsistencies that felt like hallucinations.
So how do you solve the problem of phantom reading? It's obvious that we're going to want to improve the status of reading, and I'm going to read it twice and you have to wait two times for me to write it, that's repeatable read repeatable, read the transaction began, love how to read how to read, write me aside, so there will be no phantom reading, This level is a step higher than read commited.
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