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
10
votes
3 answers

How to preload tables into INNODB buffer pool with MySQL?

I have an e-commerce application that uses MySQL, and I'd like it to be faster. When a part # is accessed on the website that has been accessed before, the part loads quickly because all the necessary data is already in the INNODB buffer pool.…
Nick
  • 101
  • 1
  • 3
10
votes
3 answers

MySQL (InnoDB): need to delete column, and accompanying foreign key constraint and index

Here's my table: CREATE TABLE `alums_alumphoto` ( `id` int(11) NOT NULL auto_increment, `alum_id` int(11) NOT NULL, `photo_id` int(11) default NULL, `media_id` int(11) default NULL, `updated` datetime NOT NULL, PRIMARY KEY …
nmjk
  • 749
  • 3
  • 9
  • 25
10
votes
3 answers

Mysql InnoDB Operating system error number 32 in a file operation on Windows

Since a few days ago, MySQL server on my Windows machine was not successful on closing itself. I found multiple instance of these lines in the MySQL error log: InnoDB: Operating system error number 32 in a file operation. InnoDB: The error means…
Cédric Girard
  • 3,358
  • 7
  • 37
  • 52
10
votes
2 answers

how to avoid deadlock in mysql

I have the following query (all tables are innoDB) INSERT INTO busy_machines(machine) SELECT machine FROM all_machines WHERE machine NOT IN (SELECT machine FROM busy_machines) and machine_name!='Main'…
olamundo
  • 23,991
  • 34
  • 108
  • 149
10
votes
3 answers

Can I use InnoDB and MyISAM tables in ONE database?

Obviously both have their benefits. MyISAM is fast but may get currupted easily, InnoDB is slow but is more stable thanks to transactions and foreign keys. So it could be good to mix both engines in one database. If that's possible?
openfrog
  • 40,201
  • 65
  • 225
  • 373
10
votes
2 answers

Foreign keys for myISAM and InnoDB tables

I have a DB table that is myISAM, used for fulltext searching. I also have a table that is InnoDB. I have a column in my myISAM table that I want to match with a column in my InnoDB table. Can that be done? I cant seem to work it out!
Becs Carter
  • 1,250
  • 1
  • 12
  • 27
10
votes
4 answers

How can I access MySQL InnoDB index values directly without the MySQL client?

I've got an index on columns a VARCHAR(255), b INT in an InnoDB table. Given two a,b pairs, can I use the MySQL index to determine if the pairs are the same from a c program (i.e. without using a strcmp and numerical comparison)? Where is a MySQL…
jmilloy
  • 7,875
  • 11
  • 53
  • 86
10
votes
2 answers

Deadlocks on MySQL deleting rows

We have a (currently InnoDB) table which contains roughly 500,000 rows. This represents a queue of tasks to run. It is stored in a MySQL database. An a continual basis, at least once per second but sometimes more frequently, we select data from it…
ChrisInEdmonton
  • 4,470
  • 5
  • 33
  • 48
10
votes
2 answers

With PHP and MySQL, should you check for rollback failures?

I'm using PHP's mysqli library. Database inserts and updates are always in a try-catch block. Success of each query is checked immediately (if $result === false), and any failure throws an exception. The catch calls mysqli_rollback() and exits with…
giskard22
  • 743
  • 1
  • 6
  • 15
10
votes
3 answers

MySQL InnoDB database restore

I have to restore a database that has been inadvertently DROPped in MySQL 5.0. From checking the backup files, I only seem to have .FRM files to hold the database data. Can anyone advise whether this is all I need to perform a database…
Jaymie Thomas
  • 812
  • 2
  • 10
  • 22
10
votes
1 answer

How to fix InnoDB dirty pages?

When I issue the SHOW GLOBAL STATUS; MySQL command, one of the lines I get is the following: Innodb_buffer_pool_pages_dirty 28 When I look up the documentation, all I see is: The number of pages currently dirty. Added in MySQL 5.0.2. How can I…
Max
  • 12,794
  • 30
  • 90
  • 142
9
votes
3 answers

Performance difference between Innodb and Myisam in Mysql

I have a mysql table with over 30 million records that was originally being stored with myisam. Here is a description of the table: I would run the following query against this table which would generally take around 30 seconds to complete. I would…
opike
  • 7,053
  • 14
  • 68
  • 95
9
votes
4 answers

inno db isolation levels and locking

I am reading a manual about innodb transactions but still, there is lots of unclear stuff to me. For instance, I don't quite understand to the following behaviour: -- client 1 -- client 2 mysql> create table simple (col…
clime
  • 8,695
  • 10
  • 61
  • 82
9
votes
2 answers

How can I override the ENGINE=INNODB parameter while importing a MySQL dump file?

I have a big dump (tens of GB) and I would like to import it into a new table without respecting the ENGINE=INNODB parameter. I tried several editors dedicated for large files to edit the dump but it always takes a lot of time to save the…
Erwin Mayer
  • 18,076
  • 9
  • 88
  • 126
9
votes
4 answers

InnoDB vs. MyISAM insert query time

I have a large MySQL table (~10 Million Rows, 6.5G) Which i use for read & write. It is MyISAM, and i get a lot of locks due to MyISAM's all table lock on writes. I decided to try and move to InnoDB which is recommended for read/write tables, and it…
normalppl
  • 297
  • 2
  • 12