mysql innodb storage engine


--MySQL structure consists of two parts
1.MySQL server layer
2. Storage Engine layer

- Note: Prior to the storage engine layer belongs to MySQL server layer

MySQL 5.1 to 5.7 version is no big change, the only change is the small version of the storage engine, MySQL server layer has not changed

After MySQL 5.5 including 5.5, is the default storage engine InnoDB (InnoDB Engine =), but in versions prior to 5.5, the default storage engine is myisam, based on the table
so if a version prior to 5.5, when the need to create a table Specifies the engine = innodb, or create out of the storage engine tables are myisam
basically is 5.1 after a 5.5; is a springboard for the period

 

MySQL components:
1. Component connection pool
2. The management service and tool assembly
3.SQL interface component
4. Query analyzer component
5. The optimizer component
6. The buffer component
7. pluggable storage engine
8. physical file

Storage engine is based on the table, not on the database

The core is the storage engine mysql

      MySQL table storage engine

MySQL pluggable storage engine architecture provides a range of standard management and service support
storage engine is based on the table, not on the database of
suitable storage engine selection according to specific application

OLTP: online online transaction system, --- reading and writing less, such as: electricity supplier, supports row-level locking, foreign key support
OLAP: line analysis system, --- the small chance of contact

      Introduction of various types of storage engine

A, innodb storage engine
1. Support Services, for online transaction processing (OLTP) aspects of the application, supports row-level locking, support for foreign keys
2. to achieve high concurrency through multi-version concurrency control MVCC, and to achieve a standard sql four isolation level (default Repeatable)
3. insert buffer provide (insert buffer), the secondary write (double write), adaptive hash index (AHI), the pre-read (read Ahead)
4. for the data stored in the table, innodb using clustered; each table are stored in the order of the primary key storage, it is not displayed if the primary key table definition,
InnoDB will produce a 6-byte rowid for each one row, as a primary key

1> Support Services, row level locking support foreign keys
2> multi-version concurrency control (MVCC) to achieve high concurrency
3> sql four standard isolation levels: repeatable read, non-repeatable read, a serial readout, dirty read
4> innodb three characteristics: INSERT Buffer, Double the Write, AHI
5> be sure to specify a primary key for each new table, do not let the system automatically creates

Two, Myisam storage engine

1. does not support transactions, table locks, full-text indexing of online analytical processing OLAP, operating speed
2. Myisam storage engine tables by the MYD and MYI composition, myd used to store data files, myi used to store the index file
3. MySQL MySQL 5.0 beginning supported by default 256T single-table data
4. for Myisam table storage engine, MySQL database cache only its index files, cache data file is handed over to the operating system itself to complete, distinct from the data cache algorithm using LUR most database

1> does not support transactions, table-level locking, full-text indexing of OLAP-line analysis systems, operation speed
2> MYD store data files, MYI store the index file
3> MySQL5.0 from the beginning, MySQL supports 256T single default data in Table
4> for myisam table storage engine, MySQL database cache only its index files, cache data file is handed over to the operating system itself to complete, different from most of the database using the data cache algorithm LUR

Three, the NDB storage engine
1. All the data in memory, so the speed of the primary fast key lookup, a database can be improved linearity performance, high availability, high-performance cluster system
connected to the storage engine 2.NDB operation is done in a MySQL database layer instead of the storage layer performs the engine, so the connecting operation requires a large complex network overhead

MySQL cluster use is the NDB storage engine, the storage engine skips directly call the data, this is not the reasons for choosing MySQL cluster of (electricity supplier will not be used)

Four, memory storage engine
1. The data in the table stored in memory, if a database restart or crash occurs, the data in the table are lost; suitable for temporary data storage temporary tables, data warehouse dimension tables,
default hash index is not B-tree index

2. only support table lock, the concurrent performance difference does not support text and blob types, when storing variable-length field varchar, is in accordance with the steady field char manner, waste of memory space

- Note: Understanding a bit memory table, a temporary table; poor concurrent performance, memory space is wasted

Five, archive storage engine only supports insert and select queries;

Six, federated storage engine does not store data, but point to the table on a remote MySQL database server

Seven, maria storage engines, caching data and index files, line lock, provided MVCC features, transactional and non-transactional security options support,
and better handling performance character type BLOB

maria storage engine, is mariadb default storage engine, and innodb is the same, MVCC (multi-version concurrency control)

 

--- summary
innodb three characteristics:
insert buffer (insert buffer); secondary write (double write); adaptive hash index (ahi)

clustered storage gather

In a production environment, you must specify the new table to create a primary key, otherwise the system will generate UID, consume system performance

innodb concurrency strong, because there are row-level locking

MyISAM: MYD storing data files; MYI index files, cache only the index data or files on disk
innodb: IBD all the files are put together, the data and indexes are cached, so fast speed innodb


[root@rc-mysql mysql]# ll user.*
-rw-rw---- 1 mysql mysql 10684 Apr 28 2016 user.frm
-rw-rw---- 1 mysql mysql 7500 May 22 16:44 user.MYD
-rw-rw---- 1 mysql mysql 4096 May 22 16:44 user.MYI

frm is the table structure, and in innodb myisam are suffix
MYD Myisam storage engine data files
MYI Myisam storage because the index file
extension ibd, data and index innodb storage engine in a file inside
innodb table data is indexed, the index is data


--- Summary: The
difference between innodb and myisam of
1. Transaction (innodb support, myisam not supported)
2. lock granularity (innodb row-level locking, myisam table-level locking)
3. Concurrent (innodb support multi-version concurrency control -MVCC, get high concurrency)
4. cache files (innodb cache data and indexes, myisam only cache index, does not cache data)
5. filename suffix (innodb: IBD; MyISAM MYD MYI)
6.5.6 after 5.6 includes support full-text indexing, but not Chinese support (innodb does not support full-text indexing in 5.6 before)
---- 5.5, including 5.5, is the default storage engine InnoDB
---- (engine = InnoDB), but the previous version 5.5, storage engines are myisam, based on the table
7.innodb perform delete time line by line is deleted because row-level locking, and does not delete the table
myisam is to delete the entire table, and then re-create the table structure in the same table
8.select count (*) ;
MyISAM is faster than innodb, because there are a counter , when there is incoming data, statistics and counter innodb table needs to be a full table scan

---- problems
1.MySQL does not support full-text indexing?
5.6 began to support full-text indexing, but only non-Chinese in the query
2.MySQL fast because they do not support transactions?
innodb support services
3. When the table is greater than one million, MySQL performance would drop dramatically?
It is; but you can not let a table is greater than a million, sub-table;
or to a structure, such as Baidu architecture (proxy mode)

 

Guess you like

Origin www.cnblogs.com/ss-33/p/11237897.html