In depth analysis based on the Mysql storage engine

  • 2020-05-17 06:44:07
  • OfStack

There are many storage engines for MySQL, and you can choose the right one for each table for different applications, which will help improve MySQL performance.
Create the news table news:


CREATE  TABLE `sandbox`.`news` 
(  
    `id` INT NOT NULL AUTO_INCREMENT ,  
    `name` VARCHAR(45) NULL ,      
    `content` VARCHAR(45) NULL ,  
    `created` VARCHAR(45) NULL ,  
    PRIMARY KEY (`id`) 
) ENGINE = MyISAM;

Note that MySQL is case-insensitive, depending on the platform you are using; Mysql is case-insensitive under Windows; On the Linux platform, MySQL is case sensitive.
ENGINE= "storage engine name", which means to select a storage engine for a table. MySQL allows us to select different storage engines when creating a table. What storage engines does MySQL have?

MySQL storage engines include: MyISAM engine, MyISAM Merge engine, InnoDB engine, Memory engine, Archive engine, CSV engine, Federated engine, Blackhle engine, NDB Cluster engine, Falcon engine, SolidDB engine, PBXT engine,
Maria engine and other engines. When building a table, it is important to choose the right storage engine, if the later replacement will be very troublesome. Here, we will only introduce three common storage engines:

MyISAM engine
The MyISAM engine is the default storage engine for MySQL. MyISAM does not support transaction and row-level locking, so the MyISAM engine is fast and has excellent performance. MyISAM locks entire tables, supports concurrent inserts, and supports full-text indexes.
If you don't need transaction support, we usually use the MyISAM storage engine when we build tables, and there is no need to support transactions for things like news tables.

InnoDB engine
InnoDB is a storage engine designed for transactions. It supports transactions, foreign keys, and high concurrency. However, InnoDB is slower than MyISAM in creating indexes and loading data.
When it comes to currency operations 1 you generally need support transactions, everything can go wrong, money can't go wrong.

Memory engine
Memory table, Memory engine stores data in memory, table structure is not stored in memory, the query does not need to perform I/O operation, so it is many times faster than MyISAM and InnoDB, but the database power or restart, the data in the table will be lost, table structure will not
Lost. If you need to store SESSION data in a database, the Memory engine is a good choice.
Usually, we use these three storage engines, please refer to the MySQL manual for more information.


Related articles: