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

VARCHAR vs TEXT performance when data fits on row

mysql> desc temp1; +-------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+-------+ | value | varchar(255) | YES | | NULL | …
vinieth
  • 1,204
  • 3
  • 16
  • 34
12
votes
2 answers

MySQL not updating information_schema, unless I manually run ANALYZE TABLE `myTable`

I have the need to get last id (primary key) of a table (InnoDB), and to do so I perform the following query: SELECT (SELECT `AUTO_INCREMENT` FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = 'mySchema' AND `TABLE_NAME` = 'myTable') -…
Oliver
  • 926
  • 2
  • 12
  • 31
12
votes
4 answers

Moving MySQL InnoDB database to separate drive

In my MySQL installation I have one InnoDB database that I know will grow very large so I have decided to move it to its own disk. I was hoping to do this by moving the files to the other disk and then create a symlink but I run into errors! This is…
Norling
  • 1,153
  • 2
  • 10
  • 24
12
votes
7 answers

mysql change innodb_large_prefix

I just setup debian 8.3 on a VM and installed xampp after this Tutorial. Everything is working, until I tried to create a new table: create table testtable ( id int(10) not null auto_increment, firstname varchar(255) collate utf8mb4_german2_ci…
yangsunny
  • 656
  • 5
  • 13
  • 32
12
votes
6 answers

Restore table structure from frm and ibd files

I am trying to restore a database in PMA but only have access to frm and ibd files - not the ib_log files which I understand you need. I know I may not be able to recover the database data but is it possible to recover the structure of the tables…
fraggley
  • 1,215
  • 2
  • 9
  • 19
12
votes
5 answers

phpMyAdmin foreign key drop-down field values

I'm using phpmyadmin (php & mysql) and I'm having a lot of trouble linking the tables using foreign keys. I'm getting negative values for the field countyId (which is the foreign key). However it is linking to my other table fine and it's cascading…
user297283
12
votes
1 answer

Correct exception handling with python MySQLdb connection

I created a small/basic python script to insert data into a MySQL database. I included some error handling - mainly to close the connection and/or prevent hanging connections in the case of an error (...but also to ignore some errors). I thought…
djmac
  • 827
  • 5
  • 11
  • 27
12
votes
2 answers

Mysql changing table engine MyISAM to InnoDB

On my site I have a visitor's table with 10 million rows. Every request to the site inserts row to the table, in case the table is locked (usually in optimize query) visitors can't get into the site The table engine is MyISAM and I want to change…
Idob
  • 1,620
  • 4
  • 16
  • 27
12
votes
1 answer

Error while trying to retrieve expired object from memcached

I'm trying to learn how to use the memcached plugin in MySQL 5.6. I used telnet to get and set values to memcached. When I try to get an expired value from memcache, it says "Connection closed by foreign host.". More details are below: database…
12
votes
7 answers

EC2 MySQL crashing continuously

I have an EC2 instance set on the x64 amazon linux ami. I am using PHP & Wordpress with W3 total cache & php-apc backed by MySQL to test a blog which can handle a decent number of connections relatively cheaply. However, my mysql keeps crashing…
David
  • 34,836
  • 11
  • 47
  • 77
12
votes
3 answers

"The total number of locks exceeds the lock table size" Deleting 267 Records

I'm trying to delete 267 records out of about 40 million. The query looks like: delete from pricedata where pricedate > '20120413' pricedate is a char(8) field. I know about adjusting innodb_buffer_pool_size, but if I can do select from…
davej
  • 1,350
  • 5
  • 17
  • 34
11
votes
2 answers

InnoDB inserts very slow and slowing down

I have recently switched my project tables to InnoDB (thinking the relations would be a nice thing to have). I'm using a PHP script to index about 500 products at a time. A table storing word/ids association: CREATE TABLE `windex` ( `word`…
nick
  • 2,743
  • 4
  • 31
  • 39
11
votes
2 answers

improving performance of mysql load data infile

I'm trying to bulk load around 12m records into a InnoDB table in a (local) mysql using LOAD DATA INFILE (from CSV) and finding it's taking a very long time to complete. The primary key type is UUID and the keys are unsorted in the data files. I've…
Michael
  • 210
  • 2
  • 7
11
votes
2 answers

Is 'update tokens set tokens = tokens + 1' atomic in InnoDB?

Without using explicit transactions, is: update tokens set tokens = tokens + 1 guaranteed to be atomic in InnoDB?
Limbeh
  • 221
  • 1
  • 7
11
votes
3 answers

InnoDB "The Table is Full" error

I have a MySQL InnoDB table on a RedHat Enterprise Linux 4 server, and after trying to import a database previously backed up using mysqldump I got a "the table is full" error. The table currently has 463,062 rows in it, and the ibdata1 file on…
andygeers
  • 6,909
  • 9
  • 49
  • 63