Home  >  Article  >  Database  >  MySQL的transaction level对django的影响

MySQL的transaction level对django的影响

WBOY
WBOYOriginal
2016-06-07 16:52:26891browse

默认: transaction level对mysql是REPEATABLE READ, 这样一个mysql session内,每次读到的资料都是不变的, 不管其他事务对表做了什

默认: transaction level对mysql是REPEATABLE READ, 这样一个mysql session内,每次读到的资料都是不变的, 不管其他事务对表做了什么更新. 这样性能比较高, 但却未必是得到准确的符合数据库最新情况的资料, 可能程序里会遭遇一些异常, 例如django的get_or_create()调用执行碰到奇怪: 明明是无法get, 自动转做create,但数据库就说记录冲突.

应该: 改用READ COMMITTED, 这是与Oracle一致的.

在my.cnf里[mysqld]下写:

transaction-isolation=READ-COMMITTED

mysql> select @@global.tx_isolation;
+———————–+
| @@global.tx_isolation |
+———————–+
| READ-COMMITTED |
+———————–+
1 row in set (0.03 sec)

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn