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

MySQL excessive memory usage

I have an installation of MySQL which allocates a lot more memory than I expected. I'd like to understand where it has gone to fix the root cause. To estimate the RAM usage I use this formula: key_buffer_size + query_cache_size +…
DocDbg
  • 427
  • 1
  • 5
  • 13
14
votes
2 answers

What is innodb_buffer_pool_size & innodb_log_file_size?

Can anyone tell me what is innodb_buffer_pool_size & innodb_log_file_size? What will happen after increasing it's sizes..
Vee
  • 139
  • 1
  • 1
  • 4
14
votes
2 answers

Clarifying the difference between row-level lock in InnoDB engine and table-level lock in MyISAM engine in MySQL database

Let us say that I have two users trying to reach a table in the database called "comments" in the following order: User1 is making and update for a record with id = 10 UPDATE comments SET comment="Hello World" WHERE id=10 User2 is making a select…
Basel
  • 359
  • 3
  • 16
14
votes
2 answers

MySQL foreign key ON DELETE SET NULL check data types error

I'm working on a normalised database, to be secure I wanted to use foreign keys. My database: CREATE TABLE `names` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(250) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`), KEY…
Maarten de Graaf
  • 516
  • 2
  • 5
  • 20
14
votes
1 answer

Setting correct innodb_log_file_size in mysql

We ran an alter table today today that took down the DB. We failed over to the slave, and in the post-mortem, we discovered this in the mysql error.log InnoDB: ERROR: the age of the last checkpoint is 90608129, InnoDB: which exceeds the log group…
timsabat
  • 2,208
  • 3
  • 25
  • 34
14
votes
1 answer

How is it possible to have deadlocks without transactions?

My code is a bit of a mess, I'm not sure where the problem is, but I'm getting deadlocks without using any transactions or table locking. Any information about this would help. I've looked up deadlocks and it seems the only way to cause them is by…
Farzher
  • 13,934
  • 21
  • 69
  • 100
14
votes
6 answers

How to change MySQL Primary Key from signed to unsigned?

In my MySQL InnoDB Database with foreign keys I accidentally made some of my primary keys signed instead of unsigned as I want them to be. Now I want to change it with a ALTER TABLE statement but it does not work: ALTER TABLE `users` CHANGE `id`…
Norwald2
  • 695
  • 4
  • 9
  • 19
13
votes
4 answers

Should I use MyISAM or InnoDB Tables for my MySQL Database?

I have the following two tables in my database (the indexing is not complete as it will be based on which engine I use): Table 1: CREATE TABLE `primary_images` ( `imgId` smallint(6) unsigned NOT NULL AUTO_INCREMENT, `imgTitle` varchar(255)…
stefmikhail
  • 6,877
  • 13
  • 47
  • 61
13
votes
2 answers

Difference in required time to insert InnoDB/MyISAM records

I'm inserting records into a MySQL table and try to understand the differences in time it takes between a MyISAM table and a InnoDB table. This is the code to create the table: CREATE TABLE SpectrumData ( ID INT(11) NULL DEFAULT NULL, `Set`…
waanders
  • 8,907
  • 22
  • 70
  • 102
13
votes
1 answer

Can Alter Table Engine = InnoDB be run on multiple tables at the same time?

When it comes to MySQL and PHPMyAdmin, I'm not a novice, but I'm closer to novice than expert. Hopefully what I ask for is doable, and that someone will provide me with a simple, cut-n-paste SQL query to make it happen. I need to convert around 9…
iampariah
  • 155
  • 1
  • 8
13
votes
5 answers

How can I determine when an InnoDB table was last changed?

I've had success in the past storing the (heavily) processed results of a database query in memcached, using the last update time of the underlying tables(s) as part of the cache key. For MyISAM tables, that last changed time is available in SHOW…
David M
  • 4,325
  • 2
  • 28
  • 40
13
votes
1 answer

delete operation locks whole table in innodb

I have an issue with table locking in InnoDB on delete operation. I have a table queue with for example one column and a lot of transactions which can insert rows into this queue or delete them. There isn't any two transactions working with the same…
Vadim Babaev
  • 490
  • 1
  • 3
  • 13
13
votes
6 answers

What's the quickest way to dump & load a MySQL InnoDB database using mysqldump?

I would like to create a copy of a database with approximately 40 InnoDB tables and around 1.5GB of data with mysqldump and MySQL 5.1. What are the best parameters (ie: --single-transaction) that will result in the quickest dump and load of the…
Josh Schwartzman
  • 243
  • 1
  • 2
  • 7
13
votes
2 answers

InnoDB Bottleneck: Relaxing ACID to Improve Performance

After noticing that our database has become a major bottleneck on our live production systems, I decided to construct a simple benchmark to get to the bottom of the issue. The benchmark: I time how long it takes to increment the same row in an…
BrainCore
  • 5,214
  • 4
  • 33
  • 38
12
votes
2 answers

How can I see global locks in mysql (innodb)?

If in understand correctly, running FLUSH TABLES WITH READ LOCK acquires a global read lock. Is there any command I can run in the mysql client which shows me that lock is currently acquired?
davidbrai
  • 1,229
  • 1
  • 9
  • 14