Two MySQL storage engine

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_41948075/article/details/100130937

I do not know you have not noticed database table often see such a ENGINES = InnoDB DEFAULT, there is no wonder What do you mean? That study together it ~
Here Insert Picture Description

Database Engine

The database engine is the core service for storing, processing and data protection.
When you access the database, whether it is manual access, or access program, not directly read and write the database files, but to access the database through the database engine file

Comparison of the two storage engine mysql

Before using the default MyISAM MySQL5.5, after 5.6 defaults to InnoDB

InnoDB features introduction and application scenarios
InnoDB transactional database engine of choice for the support of transaction-safe tables (ACID), supports row locking and foreign keys, the default storage engine for the MySQL database version 5.6 and later.

MyISAM and InnoDB are many people in the two most commonly used with MySQL storage engines, both have advantages and disadvantages, depending on the specific application.
The basic difference is:

  • MyISAM only supports table locks ; does not support foreign keys .
  • InnoDB supports foreign keys ; for InnoDB table contains a foreign key fail turn MYISAM;
  • MyISAM does not support transactions advanced processing, it emphasized that performance , its execution speed faster than InnoDB, but does not provide transaction support, and InnoDB provides transaction support advanced database features, such as an external key.

If the data table is mainly used to insert and query records, MyISAM can provide high processing efficiency; if you want to provide commit, rollback, crash recovery capabilities of transaction-safe (ACID compliant) capabilities, and requirements to achieve concurrency control, InnoDB is a Good choice.

ACID do not know what's going to understand children's shoes can Oh, when asked to interview more often. We can look at this isolation level database transaction characteristics and the four things

Lock MyISAM and InnoDB storage engine used

MyISAM uses table-level lock (table-level locking).
InnoDB supports row-level locking (row-level locking) and table-level locking, defaults to row-level locking

Database lock

Page level: Engine BDB
table level: MyISAM engine
line-level: engine INNODB

Table-level lock : Small overhead, lock fast; not deadlock; lock large size, the probability of lock conflicts of the highest, lowest degree of concurrency;
row-level locking : large overhead, locking slow; there will be a deadlock; locking granularity the smallest, lowest probability, concurrency conflicts also occur lock up;
page lock : locking overhead and time boundaries between the table and row locks; there will be a deadlock; locking granularity boundary between the table and row locks, concurrent degree in general.

Application: From the point of view of the lock, table-level locking is more suitable to check the main, only a few are applied in the index update condition data, such as Web applications; and row-level locking is more suitable for a large number of small amount of concurrent updates by index conditions different data applications, while there are concurrent queries, such as some online transaction processing (OLTP) systems.

Check the database engine command
to view all MySQL storage engines provided

show engines

Here Insert Picture Description
From the graph we can see the current default MySQL storage engine is InnoDB, and 5.7 versions of all of the InnoDB storage engine is only transactional storage engine, which means that only InnoDB support transactions.

View the current default MySQL storage engine

, we can also use the following command to view the default storage engine.

show databases; # 先查看数据库名
use databse_name; # 进入数据库
show tables_name; # 查看数据库中的表

show table status like "table_name";

Here Insert Picture Description
After a brief Complete understanding of the database engine but also to understand the database indexes , both associated with relatively strong, but also often interview test sites ~~

Guess you like

Origin blog.csdn.net/weixin_41948075/article/details/100130937