MySQL you must understand the storage engine
This article brings you relevant knowledge about mysql, which mainly introduces issues related to storage engines, and also includes issues such as index design and use, data type selection, and character set settings. ,I hope everyone has to help.
Recommended study: mysql tutorial
Who said that MySQL querying tens of millions of data is very stretched? Today I will have a good time chatting with you, talk late into the night, and spend New Year's Eve together! This article is also the last one of the year. I hope it can bring you some gains. Unknowingly, I have written so many documents and reference physical books, and I feel surprised. I can’t help but feel that the more you know, the more you know you don’t know.
Developers should pay attention to the storage engine used by MySQL. Choosing the appropriate storage engine will obviously improve the performance of your application. When reading this article, you must have some basic knowledge of MySQL or other databases, otherwise it will be very difficult to read some parts. I have bolded the key points to make it easier to access key knowledge points.
Regarding storage engines, it is impossible for one article to cover everything, and to elaborate on the aspects that I personally think are important and beneficial to my work. If we really dig into it, it would probably take the length of a book. By the way, some data type selection, character set settings, and the use of indexes are also introduced; views, stored procedures, functions, triggers, etc. will be described in detail in the next blog post. But this article will not go into too much detail. This article focuses on the selection of storage engines. If there are any flaws, I hope you can leave your valuable suggestions.
I discovered a magical parameter today: -site:xxxx.net
1. Storage Selection of engine (table type)
1. Introduction to storage engine
The difference from most relational databases is that MySQL has the concept of a storage engine, and you can choose the best one for different storage needs. A suitable storage engine. The plug-in storage engine in MySQL is a major feature. Users can choose how to store, whether to index, and whether to use transactions according to the needs of the application. Hehe, you can also adapt the storage engine that is most suitable for your business according to the business environment.
Oracle sensed business opportunities, acquired MySQL, and has since then had an enterprise version (commercial support). The community version is still available for free download. Another great charm is also because of open source, the community is highly active and everyone can contribute. Next, we will introduce several commonly used storage engines. There is no distinction between good and bad storage engines. There is only one that is more suitable for the corresponding production business environment.
The storage engines supported in MySQL5.0 are FEDERATED, MRG_MYISAM, MyISAM, BLACKHOLE, CSV, MEMORY, ARCHIVE, NDB Cluster, BDB, EXAMPLE, InnoDB (the default storage engine after MySQL5.5 and MariaDB10.2), PERFORMANCE_SCHEMA (unconventional storage data engine). The following is a comparison of the storage engines supported by MySQL and MariaDB. It can be seen that MariaDB has added the Aria engine:
View storage engine
Enter show engines\G;
through the character interface that comes with MySQL login, or use tools that support MySQL query, such as SQLyog, phpMyAdmin, MySQL workbench, etc. to query supported engines. Only some of them are shown here:
[test@cnwangk ~]$ mysql -uroot -p Enter password: mysql> show engines\G;*************************** 2. row *************************** Engine: MRG_MYISAM Support: YES Comment: Collection of identical MyISAM tablesTransactions: NO XA: NO Savepoints: NO*************************** 3. row *************************** Engine: MyISAM Support: YES Comment: MyISAM storage engineTransactions: NO XA: NO Savepoints: NO*************************** 6. row *************************** Engine: MEMORY Support: YES Comment: Hash based, stored in memory, useful for temporary tablesTransactions: NO XA: NO Savepoints: NO*************************** 8. row *************************** Engine: InnoDB Support: DEFAULT Comment: Supports transactions, row-level locking, and foreign keysTransactions: YES XA: YES Savepoints: YES9 rows in set (0.00 sec)
Function Description:
- Engine: Engine name (description);
- Support: Whether the current version of the database supports this storage engine, YES: Support, NO: Not supported; Supports transactions, row-level locking, and foreign keys, Personally translate this passage: Support transactions, row-level locking, and foreign keys;
- Comment: A detailed description of the storage engine, such as whether the engine supports transactions and foreign keys;
- Transactions: A description of whether the storage engine supports transactions, YES: supported, NO: Not supported;
- XA: Whether it meets the XA specification. The XA specification is an open group specification for distributed transaction processing (DTP). YES: Support, NO: Not supported;
- Savepoints: Literally means save points, whether the control of things is supported, YES: Supported, NO: Not supported.
Beep quietly, if you can read and understand some official English documents, this will help you further understand the MySQL storage engine and develop the ability to read source code or documents.
By the way, I would like to mention MariaDB, the sister of MySQL. In MariaDB, the forked version of MySQL, the new engine Aria was used before 10.2. The default storage engine used after MariaDB 10.2 is also InnoDB, which is enough to show the excellence of the InnoDB storage engine. MariaDB's API and protocol are compatible with MySQL, and some additional features have been added to support local non-blocking operations and progress reporting. This means that all connectors, libraries and applications that use MySQL will also work with MariaDB. On this basis, due to concerns about a more closed software project of Oracle MySQL, Linux distributions such as Fedora have replaced MySQL with MariaDB in the latest version, and the servers of the Wikimedia Foundation have also used MariaDB instead of MySQL.
MainSeveral storage engines that need to be understood:
- MyISAM
- InnoDB
- MEMORY
- MERGE
The following will focus on introducing several commonly used storage engines that I have recently learned from reading books, and compare the various storage engines. The difference between them helps us understand how different storage engines are used. For more details, please refer to MySQL's official documentation.
2. Features of some storage engines
Storage engine/support features | Storage restrictions | Transaction security | Lock mechanism | B-tree index | Hash index | Full-text index | Cluster index | Data cache | Index cache | Data can be compressed | Space usage | Memory usage | Batch insert speed | Foreign key support |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
MyISAM | has | table lock | support | Support | Support | Low | Low | High | ||||||
64TB | Support | Row lock | Support |
Support (5.6) |
Support | Support | Support | ##High | HighLow | Support | MEMORY | |||
#table lock | supportsupport |
Support |
N/A | MEDIUM |
HIGH |
MERGE |
||||||||
Table lock |
Support |
##Support |
Low | Low | HighNDB | has|||||||||
row lock | support |
##Support | SupportLow | 高 |
高 |
The above is the detailed content of MySQL you must understand the storage engine. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting

Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.
