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
137
votes
4 answers

Howto: Clean a mysql InnoDB storage engine?

Is it possible to clean a mysql innodb storage engine so it is not storing data from deleted tables? Or do I have to rebuild a fresh database every time?
700 Software
  • 85,281
  • 83
  • 234
  • 341
133
votes
8 answers

What is InnoDB and MyISAM in MySQL?

What is InnoDB and MyISAM in MySQL ?
user130561
  • 1,483
  • 3
  • 12
  • 9
112
votes
9 answers

Bogus foreign key constraint fail

I get this error message: ERROR 1217 (23000) at line 40: Cannot delete or update a parent row: a foreign key constraint fails ... when I try to drop a table: DROP TABLE IF EXISTS `area`; ... defined like this: CREATE TABLE `area` ( …
Álvaro González
  • 142,137
  • 41
  • 261
  • 360
109
votes
11 answers

UUID performance in MySQL?

We're considering using UUID values as primary keys for our MySQL database. The data being inserted is generated from dozens, hundreds, or even thousands of remote computers and being inserted at a rate of 100-40,000 inserts per second, and we'll…
Patrick Lightbody
  • 4,424
  • 2
  • 28
  • 38
101
votes
5 answers

mysqldump exports only one table

I was using mysqldump to export the database, like this: mysqldump -u root -ppassword my_database > c:\temp\my_database.sql Somehow, it only exports one table. Is there something I'm doing wrong?
danieln
  • 4,795
  • 10
  • 42
  • 64
94
votes
3 answers

How do I know if a mysql table is using myISAM or InnoDB Engine?

In MySQL, there is no way to specify a storage engine for a certain database, only for single tables. However, you can specify a storage engine to be used during one session with: SET storage_engine=InnoDB; So you don't have to specify it for each…
kamal
  • 9,637
  • 30
  • 101
  • 168
94
votes
9 answers

Fulltext Search with InnoDB

I'm developing a high-volume web application, where part of it is a MySQL database of discussion posts that will need to grow to 20M+ rows, smoothly. I was originally planning on using MyISAM for the tables (for the built-in fulltext search…
brianreavis
  • 11,562
  • 3
  • 43
  • 50
90
votes
11 answers

MySQL AUTO_INCREMENT does not ROLLBACK

I'm using MySQL's AUTO_INCREMENT field and InnoDB to support transactions. I noticed when I rollback the transaction, the AUTO_INCREMENT field is not rollbacked? I found out that it was designed this way but are there any workarounds to this?
codegy
  • 2,259
  • 4
  • 25
  • 24
85
votes
1 answer

What is MySQL's default ON DELETE behavior?

I'm trying to parse the MySQL docs. They could be clearer. What they seem to be saying is that there are five possibilities: SET NULL, NO ACTION, RESTRICT, CASCADE, and SET DEFAULT. NO ACTION and RESTRICT do the same thing (prevent any DB change…
Ethan
  • 57,819
  • 63
  • 187
  • 237
84
votes
7 answers

#1025 - Error on rename of './database/#sql-2e0f_1254ba7' to './database/table' (errno: 150)

So I am trying to add a primary key to one of the tables in my database. Right now it has a primary key like this: PRIMARY KEY (user_id, round_number) Where user_id is a foreign key. I am trying to change it to this: PRIMARY KEY (user_id,…
Richard Knop
  • 81,041
  • 149
  • 392
  • 552
84
votes
7 answers

How can I rebuild indexes and update stats in MySQL innoDB?

I have experience with MS SQL server where it is possible and useful to update statistic and rebuild indexes. I can't find such option in MySQL innoDB, is there such option? If not, how MySQL database create an execution plan? Does the MySQL update…
Tomas Kubes
  • 23,880
  • 18
  • 111
  • 148
79
votes
4 answers

MySQL InnoDB foreign key between different databases

I would like to know if it's possible in InnoDB in MySQL to have a table with foreign key that references another table in a different database ? And if so, how this can be done ?
Alaa
  • 4,471
  • 11
  • 50
  • 67
77
votes
5 answers

Force InnoDB to recheck foreign keys on a table/tables?

I have a set of InnoDB tables that I periodically need to maintain by removing some rows and inserting others. Several of the tables have foreign key constraints referencing other tables, so this means that the table loading order is important. …
pcronin
  • 1,043
  • 1
  • 12
  • 17
75
votes
14 answers

Should I COUNT(*) or not?

I know it's generally a bad idea to do queries like this: SELECT * FROM `group_relations` But when I just want the count, should I go for this query since that allows the table to change but still yields the same results. SELECT COUNT(*) FROM…
grapefrukt
  • 27,016
  • 6
  • 49
  • 73
75
votes
3 answers

What are MySQL database engines?

I looked around and found some of the MySQL engines are innodb and MyISAM. Perhaps there are few more. My question is what are these database engines? What are the differences between different MySQL engines? And more importantly, How do I decide…
pavanred
  • 12,717
  • 14
  • 53
  • 59