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

AI Hentai Generator
Generate AI Hentai for free.

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



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.

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".

Create a database using Navicat Premium: Connect to the database server and enter the connection parameters. Right-click on the server and select Create Database. Enter the name of the new database and the specified character set and collation. Connect to the new database and create the table in the Object Browser. Right-click on the table and select Insert Data to insert the data.

You can create a new MySQL connection in Navicat by following the steps: Open the application and select New Connection (Ctrl N). Select "MySQL" as the connection type. Enter the hostname/IP address, port, username, and password. (Optional) Configure advanced options. Save the connection and enter the connection name.

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.

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.

Recovering deleted rows directly from the database is usually impossible unless there is a backup or transaction rollback mechanism. Key point: Transaction rollback: Execute ROLLBACK before the transaction is committed to recover data. Backup: Regular backup of the database can be used to quickly restore data. Database snapshot: You can create a read-only copy of the database and restore the data after the data is deleted accidentally. Use DELETE statement with caution: Check the conditions carefully to avoid accidentally deleting data. Use the WHERE clause: explicitly specify the data to be deleted. Use the test environment: Test before performing a DELETE operation.

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.
