INNODB engine overview

Historical overview of the INNODB storage engine:

The INNODB storage engine is the preferred storage engine for core tables in OLTP applications.

The INNODB storage engine is included in binary distributions of all mysql databases. Earlier its version was updated with the update of the mysql database.

Starting from mysql5.1, the mysql database allows storage engine developers to load the engine in a dynamic form, so that the update of the storage engine can not be limited by the version of the mysql database.

In mysql5.1, two versions of INNODB can be supported, one is a statically compiled version of INNODB, which can be regarded as an old version of INNODB, and the other is a dynamically loaded version of INNODB, officially called INNODB plugin, or INNODB1.0 .

mysqk5.5 upgraded the INNODB version to 1.1x

mysql5.6 upgraded it to 1.2x again

Comparison between versions

Older versions of INNODB: support ACID, row lock design, MVCC
INNODB1.0x inherits all the functions of the above version, adding compress and dynamic page format
INNODB1.1x inherits all the functions of the above version, adds linux AIO, multiple rollback segments
INNODB 1.2x inherits all the functions of the above versions, adds full-text index support, and adds online indexing

Background thread of INNODB:

The main function of INNODB's background thread is to refresh the data in the memory pool to ensure that the memory cache in the buffer pool is the most recent data. Second: flush the modified data files to the disk files, and ensure that INNODB can be restored to the normal state in the event of an abnormality in the database.

The INNODB storage engine is a multi-threaded model with many different background threads in the background.

1:Master Thread

It is a very core background thread, which is mainly responsible for asynchronously flushing the data in the buffer pool to the disk to ensure data consistency.

2:Io Thread

AIO (asynchronous IO) is widely used in the INNODB storage engine to process IO requests, which can greatly improve the performance of the database.

There are four IO Threads: read, write, insert buffer and log IO thread.

By default, there are 4 read threads and 4 write threads:

MariaDB [(none)]> show engine innodb status\G

--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
I/O thread 3 state: waiting for completed aio requests (read thread)
I/O thread 4 state: waiting for completed aio requests (read thread)
I/O thread 5 state: waiting for completed aio requests (read thread)
I/O thread 6 state: waiting for completed aio requests (write thread)
I/O thread 7 state: waiting for completed aio requests (write thread)
I/O thread 8 state: waiting for completed aio requests (write thread)
I/O thread 9 state: waiting for completed aio requests (write thread)

As above, the id of the reading thread is always less than the id of the writing thread.

The number of read and write threads can be controlled by the following two parameters:

MariaDB [(none)]> show variables like "innodb_%io_threads"\G
*************************** 1. row ***************************
Variable_name: innodb_read_io_threads
        Value: 4
*************************** 2. row ***************************
Variable_name: innodb_write_io_threads
        Value: 4
2 rows in set (0.01 sec)

MariaDB [(none)]>

3: Purge Thread

After the transaction is committed, the undo log used by it may no longer be needed, so it is necessary to use the Purge thread to reclaim the used and allocated undo pages. Before innodb1.1, purge was only done in the master thread. After innodb1.1 it can be done with a separate thread.

innodb_purge_threads= 1 #Can be specified in the configuration file 

#After innodb1.2, the value of its parameter can be set to be greater than 1, and multiple purge thread threads can be started

4:Page Cleaner Thread

Introduced after the innodb1.2 version, the function is to put the dirty page flushing operation in the previous version into a separate thread to reduce the burden of the master thread.

 

Reference books [MySQL technology insider -- innodb storage engine]

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324537661&siteId=291194637