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

Why remove django DATABASE_OPTIONS's "init_command set engine=INNODB" after table creation?

Docs on creating your database tables says: Another option is to use the init_command option for MySQLdb prior to creating your tables: DATABASE_OPTIONS = { "init_command": "SET storage_engine=INNODB", } This sets the default storage engine…
ajitomatix
  • 398
  • 3
  • 10
11
votes
2 answers

Trying to understand MySQL deadlock on InnoDB table

I'm trying to understand a deadlock found by MySQL during concurrent clients processing on the same tables. This is the interesting part of the "SHOW InnoDB STATUS" command: ------------------------ LATEST DETECTED…
RedGlow
  • 773
  • 7
  • 13
11
votes
6 answers

Exact count of all rows in MySQL database

I'm currently using the script SELECT SUM(TABLE_ROWS) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'Tables'; However, it's not accurate, because the engine used by my MySQL tables is InnoDB (I only realised this could be an issue now, be…
Connor Deckers
  • 2,447
  • 4
  • 26
  • 45
10
votes
3 answers

#1033 - Incorrect information in file: './database_name/table_name.frm'

I'm completely lost as to how or why this error is displaying when I go to browse the table data. The one thing I did notice was that the Storage Engine has been switched to MyISAM with InnoDB saying it has been disabled. I'm waiting to hear back…
warr0032
  • 135
  • 1
  • 1
  • 7
10
votes
1 answer

MySQL - Different Engines for Different Tables

MySQL allows you to specify a different engine for a table from the server default engine. What kind of overhead does that create though? If I wanted to join a table that uses InnoDB with a table that uses MyISAM, which engine does MySQL use to…
carlbenson
  • 3,177
  • 5
  • 35
  • 54
10
votes
2 answers

Mysql transaction rollback on failure in update

With a simple transaction as START TRANSACTION; UPDATE posts SET status='approved' where post_id='id' AND status != 'approved'; .. other queries ... COMMIT; I want to perform the transaction only once when changing the status; but the above UPDATE…
Googlebot
  • 15,159
  • 44
  • 133
  • 229
10
votes
5 answers

Error 'Unknown table engine 'InnoDB'' on query. after restarting mysql

I have mysql DB on server S1 (mysql version 5.1.41-3ubuntu12.7-log), i have created master-slave for this DB on server S2 (mysql version 5.1.54-1ubuntu4-log). the DB on S1 was using one data file (ibdata). after dumping the DB to S2 i set…
Alaa
  • 4,471
  • 11
  • 50
  • 67
10
votes
6 answers

MySQL InnoDB hangs on waiting for table-level locks

I have a big production web-application (Glassfish 3.1 + MySQL 5.5). All tables are InnoDB. Once per several days application totally hangs. SHOW FULL PROCESSLIST shows many simple insert or update queries on different tables but all having status…
Andrey
  • 101
  • 1
  • 1
  • 4
10
votes
2 answers

Delete single row from large MySql table results in "lock timeout"

I'm running MySql 5.0.22 and have a really unwieldy table containing approximately 5 million rows. Some, but not all rows are referenced by a foreign key to another table. All attempts to cull the unreferenced rows have failed so far, resulting in…
Rocjoe
  • 459
  • 4
  • 13
10
votes
1 answer

InnoDB performance tweaks

I'm switching a large table to InnoDB from myISAM. There has been a lot of discussion regarding why switching makes sense, but not much about HOW to do it while making sure the table performs well. Assuming I'll have InnoDB and MyISAM tables in on…
10
votes
4 answers

MySQL get the number of rows in an innodb table

I have a table using innodb. I know the table has roughly 89 million rows. Using SELECT COUNT(*) FROM table; takes about five minutes to run. I know that innodb is not optimized for unconditional COUNT(*) queries. How can I restructure the query to…
Wige
  • 3,788
  • 8
  • 37
  • 58
10
votes
3 answers

Unexpected Locking for Table with Primary Key & Unique Key

I've run into an innodb locking issue for transactions on a table with both a primary key and a separate unique index. It seems if a TX deletes a record using a unique key, and then re-inserts that same record, this will result in a next-key lock…
Jake McGraw
  • 55,558
  • 10
  • 50
  • 63
10
votes
3 answers

How to resolve "specified key was too long max key length is 255 bytes" in mysql?

Whenever i fire this query from one of the mysql client (emma): CREATE TABLE `tbl_mappings` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `private_id` int(11) unsigned NOT NULL, `name` tinytext NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY…
tushar patil
  • 359
  • 2
  • 4
  • 13
10
votes
6 answers

Insert row if not exists without deadlock

I have a simple table CREATE TABLE test ( col INT, data TEXT, KEY (col) ); and a simple transaction START TRANSACTION; SELECT * FROM test WHERE col = 4 FOR UPDATE; -- If no results, generate data and insert INSERT INTO test SET col = 4,…
Jesse
  • 6,725
  • 5
  • 40
  • 45
10
votes
1 answer

How to make innodb as default engine

I am trying to make Innodb as my default engine and I changed this in the my.cnf file. I set default-storage-engine=InnoDB in my.cnf file and restarted mysql but still it's not taking it. Even after restarting the server, it's still showing default…
user476554
  • 667
  • 5
  • 8
  • 12