Questions tagged [innodb]

InnoDB is an ACID-compliant transactional storage engine for MySQL that uses MultiVersion Concurrency Control (MVCC). It has been the default storage engine for MySQL since version 5.5.5

InnoDB is an ACID-compliant transactional storage engine for MySQL that uses MultiVersion Concurrency Control (MVCC) to achieve nonblocking SELECTs and very high concurrency. It has been the default storage engine for MySQL since version 5.5.5

InnoDB's MVCC supports four levels of Transaction Isolation

  • READ-UNCOMMITTED : allows a transaction to see uncommitted changes made by other transactions. This isolation level allows dirty reads, non-repeatable reads, and phantoms to occur.
  • READ-COMMITTED : allows a transaction to see changes made by other transactions only if they've been committed. Uncommitted changes remains invisible. This isolation level allows non-repeatable reads, and phantoms to occur.
  • REPEATABLE READ (default) : ensure that is a transaction issues the same SELECT twice, it gets the same result both times, regardless of committed or uncommitted changesmade by other transactions. In other words, it gets a consistent result from different executions of the same query. In some database systems, REPEATABLE READ isolation level allows phantoms, such that if another transaction inserts new rows,in the inerbal between the SELECT statements, the second SELECT will see them. This is not true for InnoDB; phantoms do not occur for the REPEATABLE READ level.
  • SERIALIZABLE : completely isolates the effects of one transaction from others. It is similar to REPEATABLE READ with the additional restriction that rows selected by one transaction cannot be changed by another until the first transaction finishes.

You can set the Transaction Isolation Level Globally, Session-Wide, or just for one Transaction:

SET GLOBAL TRANSACTION ISOLATION LEVEL isolation_level;
SET SESSION TRANSACTION ISOLATION LEVEL isolation_level;
SET TRANSACTION ISOLATION LEVEL isolation_level;

InnoDB Architecture

InnoDB Architecture

The basic infrastructure of InnoDB centers around three major files

  • ibdata1, or System Tablespace (See InnoDB Architecture)
  • ib_logfile0 (See InnoDB Architecture)
  • ib_logfile1 (See InnoDB Architecture)

In conjunction with memory structures, ibdata1 processes info for 6 basic data structures

  • Table Data Pages
  • Table Index Pages
  • Table MetaData (List of Tablespace IDs + Misc Info)
  • MVCC Records
    • Rollback Segments
    • Undo Space
  • Double Write Buffer (Allows Background Page Writes)
  • Insert Buffer (For Collecting/Processing Changes to Secondary Indexes)

InnoDB Configurations can accommodate the following

  • Separating Table Data and Index Pages from the System Tablespace
  • Storing the System Tablespace in a Raw Disk Partition
  • Creating Multiple System Tablespace Files
  • Creating Multiple Log Files
  • and more...

There is important cache known as the InnoDB Buffer Pool. As of MySQL 5.5, you can configure multiple buffer pool instances. Prior to MySQL 5.5, there is only one buffer pool instance.

4413 questions
46
votes
9 answers

Mysql InnoDB engine in Laravel

I am using laravel and laravel migration mechanism. I created tables and seted up foreign keys. But the tables are MyISSAM so no foreign keys are created. Where do I enable / configure this? (to change it to InnoDB and not in the mysql server).
DigitalWM
  • 4,406
  • 3
  • 18
  • 15
45
votes
3 answers

MySQL InnoDB: Difference Between `FOR UPDATE` and `LOCK IN SHARE MODE`

What is the exact difference between the two locking read clauses: SELECT ... FOR UPDATE and SELECT ... LOCK IN SHARE MODE And why would you need to use one over the other?
pje
  • 21,801
  • 10
  • 54
  • 70
45
votes
3 answers

mysql Fatal error: cannot allocate memory for the buffer pool

I have this error log from MySQL, any idea? Website works for some time and then I get MySQL shutdown completely after a couple of hours. 140919 10:48:27 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is…
Hakim
  • 1,242
  • 1
  • 10
  • 22
44
votes
12 answers

MySql: MyISAM vs. Inno DB!

What are the differences between MyISAM and Inno DB types in MySql?
Arron S
  • 5,511
  • 7
  • 50
  • 57
44
votes
3 answers

How to configure MySQL 5.6 LONGBLOB for large binary data

Before I ask my question a little background: I'm doing the Data Export/Import using the MySQL Workbench 6.1 of a MySQL 5.5 database from one machine to a 5.6 on another. both machines are ubuntu one 32-bit the other 64-bit. I dump the data no…
nrapopor
  • 723
  • 1
  • 5
  • 7
43
votes
4 answers

How to disable index in innodb

I'm trying to speed up bulk insert in an InnoDB table by temporary disabling its indexes: ALTER TABLE mytable DISABLE KEYS; But it gives a warning: +-------+------+-------------------------------------------------------------+ | Level | Code |…
fanchyna
  • 2,623
  • 7
  • 36
  • 38
43
votes
17 answers

MySQL error: The maximum column size is 767 bytes

When I run a program which does something with MySQL, I got this error message: 2015-06-10 15:41:12,250 ERROR app.wsutils 419 INCRON: Error: ('HY000', '[HY000] [MySQL][ODBC 5.2(w) Driver][mysqld-5.7.7-rc-log]Index column size too large. The maximum…
user3570615
  • 461
  • 1
  • 4
  • 6
42
votes
9 answers

Prevent auto increment on MySQL duplicate insert

Using MySQL 5.1.49, I'm trying to implement a tagging system the problem I have is with a table with two columns: id(autoincrement), tag(unique varchar) (InnoDB) When using query, INSERT IGNORE INTO tablename SET tag="whatever", the auto increment…
robert
  • 1,523
  • 5
  • 19
  • 27
42
votes
2 answers

Why doesn't MySQL's MyISAM engine support Foreign keys?

I am writing a web-app for my studies which includes fulltext search and foreign keys. I have read somewhere, MyISAM engine is suitable for fulltext searching, and InnoDB for foreign keys. In this situation what engine should I use for the best…
Mukilarasan
  • 747
  • 1
  • 7
  • 19
41
votes
7 answers

Magento install complains about missing InnoDB when it is available

During installation, Magento produces the following error: Database server does not support the InnoDB storage engine. I've fixed all the dependancies for Magento, and double checked with MySQL on the command line using SHOW ENGINES and definitely…
Giles Williams
  • 683
  • 1
  • 5
  • 14
40
votes
2 answers

Joining InnoDB tables with MyISAM tables

We have a set of tables which contain the meta level data like organizations, organization users, organization departments etc. All these table are going to be read heavy with very few write operations. Also, the table sizes would be quite small…
Pigol
  • 1,221
  • 2
  • 13
  • 18
39
votes
2 answers

Why does TRANSACTION / COMMIT improve performance so much with PHP/MySQL (InnoDB)?

I've been working with importing large CSV files of data; usually less than 100,000 records. I'm working with PHP and MySQL (InnoDB tables). I needed to use PHP to transform some fields and do some text processing prior to the MySQL INSERTs (part of…
jjwdesign
  • 3,272
  • 8
  • 41
  • 66
39
votes
3 answers

MySQL InnoDB: autoincrement non-primary key

Is it possible to auto-increment a non-primary key? Table "book_comments" book_id medium_int timestamp medium_int user_id medium_int vote_up small_int vote_down small_int comment text comment_id medium_int Primary key ->…
ProfileTwist
  • 1,524
  • 1
  • 13
  • 18
38
votes
8 answers

How do I repair an InnoDB table?

We (apparently) had poorly executed of our Solaris MySQL database engine last night. At least some of the InnoDB tables are corrupted, with timestamp out of order errors in the transaction log, and a specific error about the index being…
lefticus
  • 3,346
  • 2
  • 24
  • 28
37
votes
4 answers

How to set transaction isolation level (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?
Wen Jun
  • 522
  • 3
  • 9
  • 19