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

"query end" step very long at random times

I'm benchmarking a web application, and I have a problem that occurs on about 1% of my queries, mostly UPDATES (but also sometimes INSERT). I did a profiling on those requests and it seems it's the query end step that takes a lot of time. starting …
Lliane
  • 831
  • 2
  • 7
  • 15
8
votes
1 answer

Very slow writes on MySQL 8 - waiting for handler commit

I have MySQL 8 docker installation installed on an edge device which has the following two tables to write to video_paths | CREATE TABLE `video_paths` ( `entry` int(11) NOT NULL AUTO_INCREMENT, `timestamp` bigint(20) NOT NULL, `duration`…
Akshat Goel
  • 736
  • 2
  • 6
  • 19
8
votes
1 answer

MySQL distinct performance

When I add 'distinct' to my query, query time increases from 0.015 to over 6 seconds. I want to join several tables, which are linked via foreign keys and get a distinct column from it: select distinct table3.idtable3 from table1 join…
Langer
  • 97
  • 7
8
votes
4 answers

How to predict MySQL tipping points?

I work on a big web application that uses a MySQL 5.0 database with InnoDB tables. Twice over the last couple of months, we have experienced the following scenario: The database server runs fine for weeks, with low load and few slow queries. A…
Newt
8
votes
2 answers

Do MySQL transactions for INSERT lock foreign key referenced tables?

I am trying to do a huge transaction in my Java application and doing single insert entries (volume in thousands) for user_account_entry table which has foreign key reference to user table. When the transaction is running, i am not able to update…
Paras Diwan
  • 333
  • 1
  • 5
  • 13
8
votes
2 answers

How to use Limit in query on my index column without scan all rows?

Here is my table : In my table Clustering_key (Primary key and auto incremental) ID (Index Column) Data (Text datatype column) Position(Index column) maintain the order of Data My table have 90,000 rows with same ID equal to 5. I want to first 3…
Shubham
  • 183
  • 1
  • 3
  • 15
8
votes
3 answers

MySQL Update query - Will the 'where' condition respected on race condition and row locking? (php, PDO, MySQL, InnoDB)

I am trying to build a first-come first-get model sale page. We have n number of items of the same type. We want to assign these n items to the first n users who made the request. Corresponding to each item, there is a database row. When the user…
8
votes
2 answers

How is it possible for InnoDB to deadlock on a single row?

According to The Good Word, InnoDB uses automatic row-level locking. You can get deadlocks even in the case of transactions that just insert or delete a single row. That is because these operations are not really “atomic”; they automatically set…
KeatsKelleher
  • 10,015
  • 4
  • 45
  • 52
8
votes
2 answers

MySQL is not correctly selecting rows (sometimes)

This is an update to this question, wherein I was casting around trying to work out what on earth was going on: MySQL sometimes erroneously returns 0 for count(*) I ended up accepting an answer there because it did answer the question I posed ("why…
Mala
  • 14,178
  • 25
  • 88
  • 119
8
votes
1 answer

Overhead of Composite Indexes

I have many tables where I have indexes on foreign keys, and clustered indexes which include those foreign keys. For example, I have a table like the following: TABLE: Item ------------------------ id PRIMARY KEY owner FOREIGN…
Kirk Backus
  • 4,776
  • 4
  • 32
  • 52
8
votes
2 answers

Can I retrieve pending queries during an InnoDB transaction?

I start a transaction. Then I need to rollback it. Can I somehow get a list of the queries that get "discarded" this way? (ps: of course I can log them beforehand; I was wondering if this could be done in a more "natural" way)
o0'.
  • 11,739
  • 19
  • 60
  • 87
8
votes
1 answer

why is django leaving locks behind in mysql?

I have a Django app that uses MySQL and the InnoDB engine for storage. For some reason, Django sometimes leaves locks in place, even after the query has completed. (I can see them with Innotop). The only transaction-handling stuff that I do in my…
Chris Curvey
  • 9,738
  • 10
  • 48
  • 70
8
votes
2 answers

Django save() behavior with autocommit transactions

I have a following setup: Several data processing workers get configuration from django view get_conf() by http. Configuration is stored in django model using MySQL / InnoDB backend Configuration model has overridden save() method which tells…
jhonkola
  • 3,385
  • 1
  • 17
  • 32
8
votes
1 answer

After 5 years, several rows disappeared from mySQL innoDB table

I have several DDBB on InnoDB (MySQL 5.5.7. -FreeBSD). For 5 years I have not any problems. I realize periodically check tables, optimization, ... Mysteriously, a table of one of the DB has lost 20 rows from 70 (DELETE!). These rows were inserted…
BeAsT
  • 91
  • 6
8
votes
2 answers

mysql innodb:innodb_flush_method

in the following link http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_flush_method it says:Different values of this variable can have a marked effect on InnoDB performance. For example, on some systems where InnoDB data…
Daniel
  • 621
  • 3
  • 9
  • 18