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
16
votes
1 answer

Optimize innodb table

When i run optimize table on a innodb table, i get this message instead. does it mean that the table has already been optimized, but in a different manner? "table | optimize | note | Table does not support optimize, doing recreate + analyze instead…
meow
  • 27,476
  • 33
  • 116
  • 177
16
votes
2 answers

Where else can the variable innodb_buffer_pool_size be accessed besides my.cnf?

I've installed MAMP and have the latest phpMyAdmin on my Mac. I do not have a my.cnf nor a my.ini file. Yes, I have enabled all invisible files. I've heard the free version of MAMP doesn't let you, but that doesn't seem right. I know MAMPPro has a…
kelly johnson
  • 1,596
  • 3
  • 16
  • 26
16
votes
1 answer

Mysql Trigger with IF THEN

My storage is INNODB, I'm trying to create an trigger with 2 queries in IF statement. Down you can see the trigger that gives me the error delimiter | CREATE TRIGGER count_delete_videos BEFORE DELETE ON videos FOR EACH ROW BEGIN UPDATE counts…
Alex P.
  • 551
  • 1
  • 5
  • 21
15
votes
2 answers

Why is innodb's SHOW TABLE STATUS so unreliable?

I know that you shouldn't rely on the values returned by InnoDB's SHOW TABLE STATUS. In particular, the row count and avg data length. But I thought maybe it was an accurate value taken at some point, and then innodb only refreshes it during an…
carpii
  • 1,917
  • 4
  • 20
  • 24
15
votes
4 answers

MySQL INSERT ....ON DUPLICATE UPDATE - Adds one to the autoincrement

I keep track of all the http_user_agents that visit me, with a simple hit counter. The below insert the http_user_agent in the DB, this field is Case Insensitive and is Unique. So when we try to insert it and it finds a DUPLICATE KEY, it adds 1 to…
M. of CA
  • 1,496
  • 2
  • 22
  • 32
15
votes
2 answers

How to force truncate all tables(which are all innodb) in a database in MySQL?

I think I get foreign key constraint error when I try to truncate innodb tables. I was not having problems with this when using MyISAM. Is there an easy way to force truncate all tables? Or should I just make a script to drop the database, create…
developarvin
  • 4,940
  • 12
  • 54
  • 100
15
votes
5 answers

MySQL Full-text Search Workaround for innoDB tables

I'm designing an internal web application that uses MySQL as its backend database. The integrity of the data is crucial, so I am using the innoDB engine for its foreign key constraint features. I want to do a full-text search of one type of…
Rob
  • 183
  • 1
  • 1
  • 4
15
votes
1 answer

Transaction necessary for single update query?

I have a mysql query on an InnoDB table like this: UPDATE items SET qty = qty + 5 WHERE item_id = 1234 LIMIT 1; Do I need to use a transaction for this? Could anything undesirable happen by not using a transaction?
Tony H
  • 165
  • 1
  • 4
15
votes
1 answer

Deadlock issue when transaction tries to accuire a lock it's already holding

I've found a very confusing deadlock situation that I need help to understand. There are two transactions going on: (2) holds a lock for the query delete from myTable where id = NAME_CONST('p_id',10000). This is a lock by PRIMARY KEY although not…
Andreas Wederbrand
  • 38,065
  • 11
  • 68
  • 78
15
votes
10 answers

When should you choose to use InnoDB in MySQL?

I am rather confused by the hurt-mongering here. I know how to do them, see below, but no idea why? What are they for? create table orders (order_no int not null auto_increment, FK_cust_no int not null, foreign key(FK_cust_no) references…
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
15
votes
1 answer

Creating index takes too long time

About 2 months ago, I imported EnWikipedia data(http://dumps.wikimedia.org/enwiki/20120211/) into mysql. After finished importing EnWikipedia data, I have been creating index in the tables of the EnWikipedia database in mysql for about 2 month. Now,…
sensing_bot
  • 153
  • 1
  • 1
  • 5
14
votes
2 answers

symfony 1.4 propel:build-all not working on Mysql 5.5

i am using Symfony 1.4.8 and Mysql 5.5 i got this error when i run symfony propel:build-all You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near…
Bhanu Krishnan
  • 3,726
  • 1
  • 20
  • 40
14
votes
5 answers

MySQL: column size limit

I'm currently working on a Windows OS and I have installed MySQL community server 5.6.30 and everything is fine. I have a script that initializes the DB and again, everything works fine. Now I'm trying to run this script on a Linux environment --…
Tal Ben Shabtay
  • 223
  • 2
  • 4
  • 10
14
votes
3 answers

InnoDB error on mariadb oficial docker image

I’m having a very strange error. I have been able to pin it down to a very simple case and I don’t know if I have found a bug or if I’m missing some point. The thing is I need a mariadb container and I can run it perfectly with the following…
Miquel Adell
  • 1,132
  • 3
  • 11
  • 24
14
votes
5 answers

Innodb: Can't find FULLTEXT index matching the column list when queried more than 1 columns

I'm trying to run a very simple query on my MySQL INNODB table: SELECT * FROM items WHERE MATCH (item_title,item_description) AGAINST ('dog') Both column item_title and item_description have a FULLTEXT index. I keep getting this error: Can't…
Mr.Boon
  • 2,024
  • 7
  • 35
  • 48