MYSQL: InnoDB and Django transactions

  1. Always use InnoDB my.cnf:
[mysqld]
default-storage-engine = InnoDB
  1. InnoDB for session:
SET storage_engine=INNODB
  1. InnoDB per table:
CREATE TABLE employee (id INT) ENGINE = InnoDB;
ALTER TABLE employee ENGINE = InnoDB;

Also it is important to change isolation level. Because with REPEATABLE READ if the first read yield no result, any subsequent read, as it must yield the same result, won't yield anything too.

my.cnf:

# Set the default transaction isolation level.
transaction-isolation = READ-COMMITTED

Django:

DATABASE_OPTIONS = { "init_command": "SET storage_engine=INNODB, SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED", }

Comments

comments powered by Disqus