Table of Contents
InnoDB
MyISAM
Storage
Features
Locking and Concurrency – Table Lock
Repair
Index Features
MyISAM performance
Archive engine
CSV Storage Engine
Memory Engine
Explanation
Home Database Mysql Tutorial [MySQL] MySQL storage engine

[MySQL] MySQL storage engine

Feb 25, 2017 am 10:23 AM


When creating a table, you can specify the type of the table, which is the storage engine of the table. The storage engine of a table determines how data is stored and accessed, as well as how transactions are stored. The storage engine of a table greatly affects the storage space and speed required to process SQL statements. Different storage engines have different characteristics. Some storage engines are very suitable for processing many complex SELECT statements, while others are more suitable for achieving fast updates.

InnoDB

InnoDB is MySQL’s default transactional engine and the most important and widely used storage engine. It is designed to handle a large number of short-lived transactions. Short-lived transactions are submitted normally in most cases and are rarely rolled back. InnoDB's performance and automatic crash recovery features make it popular for non-transactional storage needs.

Unless there are very special reasons to use other storage engines, the InnoDB engine should be given priority. ————"High-Performance MySQL"

  • InnoDB uses MVCC to support high concurrency and implements four standard isolation levels. Its default level is REPEATABLE READ, and the gap lock strategy prevents phantom reads.

  • InnoDB indicates that

  • built based on a clustered index supports foreign key constraints.

  • Supports automatic addition of column AUTO_INCREMENT attribute.

  • Affairs. The InnoDB storage engine is a standard MySQL storage engine that supports transactions.

  • There is no need to copy the entire table data when deleting or adding an index.

InnoDB has made many internal optimizations, including predictable read-ahead when reading data from disk, and an adaptive hash index that can automatically create a hash index in memory to accelerate operations. , and an insert buffer that speeds up insert operations.

InnoDB tables are built based on clustered indexes. The index structure of InnoDB is very different from other MySQL engines. Clustered indexes have high performance for primary key queries. However, the secondary index must contain the primary key column, so if the primary key column is large, all other indexes will be large. Therefore, if there are many indexes on the table, the primary key should be as small as possible.

MyISAM

MyISAM provides a large number of features, including full-text indexing, compression, spatial functions (GIS), etc., but MyISAM does not support transactions and row-level locks, and there is no doubt that The disadvantage is that it cannot be safely restored after a crash. In MySQL 5.1 and previous versions, MyISAM is the default storage engine. It is precisely because of this engine that even though MySQL has supported transactions for a long time, many people still think that MySQL is a non-transactional database.

  • MyISAM locks the entire table, not the rows.

  • Supports full-text indexing.

  • Supports compressed tables. Compressed tables cannot be modified and can greatly reduce disk space usage, thus reducing disk I/O operations and thereby improving query performance.

Storage

MyISAM will store the table in two files: the data file and the index file, with .MYD and .MYI extensions respectively. MyISAM tables can contain dynamic or static rows. MySQL will decide which row format to use based on the table definition.
In MySQL5.0, if the MyISAM table has variable-length rows, the default configuration can only handle 256TB of data

Features

As one of the earliest storage engines of MySQL, there are still some features.

Locking and Concurrency – Table Lock

MyISAM locks the entire table, not the rows. When reading, shared locks will be added to all tables that need to be read, and exclusive locks will be added to the tables when writing. However, while the table has read queries, new records can also be inserted into the table (concurrent insertion).

Repair

For MyISAM tables, MySQL can perform inspection and maintenance operations manually or automatically, but the repair mentioned here is a different concept from transaction recovery and crash recovery.

Index Features

For MyISAM tables, even long fields such as BLOB and TEXT can create indexes based on their first 500 characters. MyISAM also supports full-text indexing, which is an index created based on word segmentation and can support complex queries.
Delayed update of index keys
When creating a MyISAM table, if the DELAY_KEY_WRITE option is specified, the modified index data will not be written to the disk immediately when each modification is completed.
 

MyISAM performance

The MyISAM engine is designed to be simple and the data is stored in a compact format, so the performance in certain scenarios is very good. However, the existence of table locks has a great impact on performance.

Archive engine

Archive storage engine only supports INSERT and SELECT. The Archive engine caches all writes and uses zlib to compress inserts, so it requires less disk I/O than MyISAM tables. But every SELECT query needs to perform a full table scan. Therefore, Archive tables are suitable for log and data collection applications, which often require full table scans for data analysis.

The Archive engine supports row-level locks and dedicated buffers, so high-concurrency insertions can be achieved. Archive will prevent other SELECTs from executing until all rows that exist in the table are returned before a query is started to achieve consistent reads. In addition, batch inserts are also implemented that are invisible to read operations until they are completed. This mechanism mimics some features of transactions and MVCC, but the Archive engine is not a transactional engine, but an engine optimized for high-speed insertion and compression.

CSV Storage Engine

This engine can process ordinary CSV files as MySQL tables, but this table does not support indexes. You only need to copy the CSV file to the data directory of the CSV storage engine, and it can be opened and used using the rules listed in MySQL.

Memory Engine

If you need to access data quickly, and the data will not be modified or lost after restarting, then using the Memory table is very useful. Memory tables are an order of magnitude faster than MyISAM tables because all data is stored in memory and no disk I/O operations are required. The structure of the Memory table will be retained after restarting, but the data will be lost.

  • Supports Hash index, so the search operation is very fast.

  • is a table-level lock, so concurrent write performance is low.

  • does not support BLOB or TEXT type columns, and the length of each row is fixed. Even if varchar is specified, it will be converted to char in actual storage.

Explanation

Unless you need to use some features that InnoDB does not have, and there is no other way to replace it, you should give priority to the InnoDB engine—— "High-Performance MySQL"

In addition, the above only lists some commonly encountered storage engines, which is not comprehensive.

When creating a table, you can specify the type of the table, which is the storage engine of the table. The storage engine of a table determines how data is stored and accessed, as well as how transactions are stored. The storage engine of a table greatly affects the storage space and speed required to process SQL statements. Different storage engines have different characteristics. Some storage engines are very suitable for processing many complex SELECT statements, while others are more suitable for achieving fast updates.

InnoDB

InnoDB is MySQL’s default transactional engine and the most important and widely used storage engine. It is designed to handle a large number of short-lived transactions. Short-lived transactions are submitted normally in most cases and are rarely rolled back. InnoDB's performance and automatic crash recovery features make it popular for non-transactional storage needs.

Unless there are very special reasons to use other storage engines, the InnoDB engine should be given priority. ————"High-Performance MySQL"

  • InnoDB uses MVCC to support high concurrency and implements four standard isolation levels. Its default level is REPEATABLE READ (repeatable read), and the gap lock strategy prevents phantom reads.

  • InnoDB indicates that

  • built based on a clustered index supports foreign key constraints.

  • Supports automatic addition of column AUTO_INCREMENT attribute.

  • Affairs. The InnoDB storage engine is a standard MySQL storage engine that supports transactions.

  • There is no need to copy the entire table data when deleting or adding an index.

InnoDB has made many internal optimizations, including predictable read-ahead when reading data from disk, and an adaptive hash index that can automatically create a hash index in memory to accelerate operations. , and an insert buffer that speeds up insert operations.

InnoDB tables are built based on clustered indexes. The index structure of InnoDB is very different from other MySQL engines. Clustered indexes have high performance for primary key queries. However, the secondary index must contain the primary key column, so if the primary key column is large, all other indexes will be large. Therefore, if there are many indexes on the table, the primary key should be as small as possible.

MyISAM

MyISAM provides a large number of features, including full-text indexing, compression, spatial functions (GIS), etc., but MyISAM does not support transactions and row-level locks, and there is no doubt that The drawback is that it cannot be safely restored after a crash. In MySQL 5.1 and previous versions, MyISAM is the default storage engine. It is precisely because of this engine that even though MySQL has supported transactions for a long time, many people still think that MySQL is a non-transactional database.

  • MyISAM locks the entire table, not the rows.

  • Supports full-text indexing.

  • Supports compressed tables. Compressed tables cannot be modified and can greatly reduce disk space usage, thus reducing disk I/O operations and thereby improving query performance.

Storage

MyISAM will store the table in two files: the data file and the index file, with .MYD and .MYI extensions respectively. MyISAM tables can contain dynamic or static rows. MySQL will decide which row format to use based on the table definition.
In MySQL5.0, if the MyISAM table has variable-length rows, the default configuration can only handle 256TB of data

Features

As one of the earliest storage engines of MySQL, there are still some features.

Locking and Concurrency – Table Lock

MyISAM locks the entire table, not the rows. When reading, shared locks will be added to all tables that need to be read, and exclusive locks will be added to the tables when writing. However, while the table has read queries, new records can also be inserted into the table (concurrent insertion).

Repair

For MyISAM tables, MySQL can perform inspection and maintenance operations manually or automatically, but the repair mentioned here is a different concept from transaction recovery and crash recovery.

Index Features

For MyISAM tables, even long fields such as BLOB and TEXT can create indexes based on their first 500 characters. MyISAM also supports full-text indexing, which is an index created based on word segmentation and can support complex queries.
Delayed update of index keys
When creating a MyISAM table, if the DELAY_KEY_WRITE option is specified, the modified index data will not be written to the disk immediately when each modification is completed.
 

MyISAM performance

The MyISAM engine is designed to be simple and the data is stored in a compact format, so the performance in certain scenarios is very good. However, the existence of table locks has a great impact on performance.

Archive engine

Archive storage engine only supports INSERT and SELECT. The Archive engine caches all writes and uses zlib to compress inserts, so it requires less disk I/O than MyISAM tables. But every SELECT query needs to perform a full table scan. Therefore, Archive tables are suitable for log and data collection applications, which often require full table scans for data analysis.

The Archive engine supports row-level locks and dedicated buffers, so high-concurrency insertions can be achieved. Archive will prevent other SELECTs from executing until all rows that exist in the table are returned before a query is started to achieve consistent reads. In addition, batch inserts are also implemented that are invisible to read operations until they are completed. This mechanism mimics some features of transactions and MVCC, but the Archive engine is not a transactional engine, but an engine optimized for high-speed insertion and compression.

CSV Storage Engine

This engine can process ordinary CSV files as MySQL tables, but this table does not support indexes. You only need to copy the CSV file to the data directory of the CSV storage engine, and it can be opened and used using the rules listed in MySQL.

Memory Engine

If you need to access data quickly, and the data will not be modified or lost after restarting, then using the Memory table is very useful. Memory tables are an order of magnitude faster than MyISAM tables because all data is stored in memory and no disk I/O operations are required. The structure of the Memory table will be retained after restarting, but the data will be lost.

  • Supports Hash index, so the search operation is very fast.

  • is a table-level lock, so concurrent write performance is low.

  • does not support BLOB or TEXT type columns, and the length of each row is fixed. Even if varchar is specified, it will be converted to char in actual storage.

Explanation

Unless you need to use some features that InnoDB does not have, and there is no other way to replace it, you should give priority to the InnoDB engine—— "High-Performance MySQL"

In addition, the above only lists some commonly encountered storage engines, which is not comprehensive.

The above is the content of [MySQL] MySQL storage engine. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

How to open phpmyadmin How to open phpmyadmin Apr 10, 2025 pm 10:51 PM

You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

MySQL: An Introduction to the World's Most Popular Database MySQL: An Introduction to the World's Most Popular Database Apr 12, 2025 am 12:18 AM

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

How to use single threaded redis How to use single threaded redis Apr 10, 2025 pm 07:12 PM

Redis uses a single threaded architecture to provide high performance, simplicity, and consistency. It utilizes I/O multiplexing, event loops, non-blocking I/O, and shared memory to improve concurrency, but with limitations of concurrency limitations, single point of failure, and unsuitable for write-intensive workloads.

Why Use MySQL? Benefits and Advantages Why Use MySQL? Benefits and Advantages Apr 12, 2025 am 12:17 AM

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

MySQL's Place: Databases and Programming MySQL's Place: Databases and Programming Apr 13, 2025 am 12:18 AM

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL and SQL: Essential Skills for Developers MySQL and SQL: Essential Skills for Developers Apr 10, 2025 am 09:30 AM

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.

Monitor Redis Droplet with Redis Exporter Service Monitor Redis Droplet with Redis Exporter Service Apr 10, 2025 pm 01:36 PM

Effective monitoring of Redis databases is critical to maintaining optimal performance, identifying potential bottlenecks, and ensuring overall system reliability. Redis Exporter Service is a powerful utility designed to monitor Redis databases using Prometheus. This tutorial will guide you through the complete setup and configuration of Redis Exporter Service, ensuring you seamlessly build monitoring solutions. By studying this tutorial, you will achieve fully operational monitoring settings

See all articles