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

Is there a simpler way to achieve this style of user messaging?

I have created a messaging system for users, it allows them to send a message to another user. If it is the first time they have spoken then a new conversation is initiated, if not the old conversation continues. The users inbox lists all…
Dan
  • 11,914
  • 14
  • 49
  • 112
27
votes
1 answer

How to do a fast but innacurate InnoDB row count?

The FAQ of PHPMyAdmin has this to say about its approximate row counts for InnoDB: phpMyAdmin uses a quick method to get the row count, and this method only returns an approximate count in the case of InnoDB tables. I would like to use this 'quick…
Grim...
  • 16,518
  • 7
  • 45
  • 61
27
votes
7 answers

How to disable SQLAlchemy caching?

I have a caching problem when I use sqlalchemy. I use sqlalchemy to insert data into a MySQL database. Then, I have another application process this data, and update it directly. But sqlalchemy always returns the old data rather than the updated…
Zeyi Fan
  • 2,213
  • 3
  • 17
  • 19
26
votes
6 answers

How can I improve DELETE FROM performance on large InnoDB tables?

I have a fairly large InnoDB table which contains about 10 million rows (and counting, it is expected to become 20 times that size). Each row is not that large (131 B on average), but from time to time I have to delete a chunk of them, and that is…
mpe
  • 1,000
  • 1
  • 8
  • 25
26
votes
2 answers

xtradb vs innodb

I was asked to check Mariadb as Centos does not provider MySQL 5.5 for the moment. I have read that xtradb servers as a drop in for innodb. What are the advantages of using one or the other because if they were equal, they would not have been…
thedethfox
  • 1,651
  • 2
  • 20
  • 38
25
votes
7 answers

Unknown table engine 'InnoDB'

Recently, I have found out that I can maximize mysql performance when if I have good hardware. Since I've been using InnoDB I added additional configuration into my.ini Here is the newly added configurations: innodb_data_file_path =…
rechie
  • 2,139
  • 5
  • 25
  • 38
25
votes
2 answers

SELECT LOCK IN SHARE MODE

i have read this article from dev.mysql. in that page is a example that when use select for update and dont use lock in share mode and says Here, LOCK IN SHARE MODE is not a good solution because if two users read the counter at the same time,…
user006779
  • 1,011
  • 4
  • 15
  • 28
25
votes
2 answers

Does the space occupied by deleted rows get re-used?

I have read several times that after you delete a row in an InnoDB table in MySQL, its space is not reused, so if you make a lot of INSERTs into a table and then periodically DELETE some rows the table will use more and more space on disk, as if the…
user1411272
25
votes
4 answers

How to enable INNODB in mysql

When I execute a query in MySQL it returns an error saying that InnoDB is not enabled. When I clicked the storage engine, the InnoDB was disabled. How do I enable InnoDB?
Shahid Karimi
  • 4,096
  • 17
  • 62
  • 104
25
votes
11 answers

Foreign key not working in MySQL: Why can I INSERT a value that's not in the foreign column?

I've created a table in MySQL: CREATE TABLE actions ( A_id int NOT NULL AUTO_INCREMENT, type ENUM('rate','report','submit','edit','delete') NOT NULL, Q_id int NOT NULL, U_id int NOT NULL, date DATE NOT NULL, time TIME NOT NULL, rate…
stalepretzel
  • 15,543
  • 22
  • 76
  • 91
24
votes
7 answers

mysql - Deleting Rows from InnoDB is very slow

I got a mysql database with approx. 1 TB of data. Table fuelinjection_stroke has apprx. 1.000.000.000 rows. DBID is the primary key that is automatically incremented by one with each insert. I am trying to delete the first 1.000.000 rows using a…
user1938509
  • 435
  • 1
  • 6
  • 15
24
votes
6 answers

MySQL: Very slow update/insert/delete queries hanging on "query end" step

I have a large and heavy loaded mysql database which performs quite fast at times, but some times get terribly slow. All tables are InnoDB, server has 32GB of RAM and database size is about 40GB. Top 20 queries in my slow_query_log are update,…
Silver Light
  • 44,202
  • 36
  • 123
  • 164
23
votes
4 answers

Should I migrate from MySQL to Percona server

I have been experiencing dirty pages flushing problem in MySQL server. This occupies lot of CPU resources and my site becomes down because of lack of resources left in server. I got 10 Million records in database and it will grow further. My tables…
devuser29
  • 233
  • 1
  • 2
  • 4
23
votes
4 answers

How to solve InnoDB: Unable to lock ./ibdata1 mysql error?

2016-03-14 02:30:29 58150 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35 2016-03-14 02:30:29 58150 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
Wojtek Dmyszewicz
  • 4,188
  • 5
  • 30
  • 42
23
votes
4 answers

How do I re-create a MySQL InnoDB table from an .ibd file?

Assume that the following MySQL files have been restored from a backup tape: tablename.frm tablename.ibd Furthermore, assume that the MySQL installation was running with innodb_file_per_table and that the database was cleanly shutdown with…
knorv
  • 49,059
  • 74
  • 210
  • 294