Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting transaction isolation level of MySQL

How do I set the isolation level of MySQL 5.1 InnoDB?

By entering:

mysql> show variables like '%isola%';

The default level set for InnoDB is repeatable read.
How do I change the isolation level?

like image 455
Wen Jun Avatar asked Oct 29 '11 07:10

Wen Jun


People also ask

What is transaction isolation level in MySQL?

Isolation is the I in the acronym ACID; the isolation level is the setting that fine-tunes the balance between performance and reliability, consistency, and reproducibility of results when multiple transactions are making changes and performing queries at the same time.

How do you level a transaction isolation?

Transaction isolation levels are a measure of the extent to which transaction isolation succeeds. In particular, transaction isolation levels are defined by the presence or absence of the following phenomena: Dirty Reads A dirty read occurs when a transaction reads data that has not yet been committed.

What is SET TRANSACTION in MySQL?

The SET TRANSACTION Statement in MYSQL is used to set the values to the characteristics of the current transaction such as transaction isolation level and access mode.

Does MySQL use snapshot isolation?

There's no snapshot isolation level in MySQL. It uses snapshot for Consistent Nonlocking Reads, but it doesn't mean it supports snapshot isolation. According to the Wikipedia page, only databases below support snapshot isolation. But the REPEATABLE READ level doesn't do this at all, though it uses snapshot.


1 Answers

SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED 

SESSION is optional, just limits the setting to the current session.
READ UNCOMMITTED is to be replaced with your desired level.

https://dev.mysql.com/doc/refman/8.0/en/set-transaction.html

like image 100
Niet the Dark Absol Avatar answered Sep 19 '22 00:09

Niet the Dark Absol