当前位置:网站首页>Advanced MySQL - storage engine
Advanced MySQL - storage engine
2022-06-29 16:34:00 【White chocolate x】
Catalog
In the last article, we learned MySQL Basics —— Business , This article is for learning MySQL Advanced —— Storage engine .
Storage engine
The storage engine is to store data 、 Index 、 to update / Query data and other technologies . Its table based , Not library based , So the storage engine is also called a table type .
While building the watch , If you do not specify a storage engine , Will use the default storage engine InnoDB, Execute the following code to view the previous table creation statement :
use mytest;
show create table account;As shown in the figure below :

You can see , The storage engine of this data table is InnoDB.
While building the watch , You can specify the storage engine , The syntax is as follows :
create table Table name (
Field 1 Field 1 type [COMMENT Field 1 notes ],
....
Field n Field n type [COMMENT Field n notes ],
)ENGINE = INNODB [COMMENT Table annotation ];Be careful : Before specifying the storage engine , You need to query the storage engines supported by the current database , The code is as follows :
show engines;As shown in the figure below :

InnoDB
InnoDB It is a general storage engine with high reliability and high performance , stay MySQL5.5 after ,InnoDB By default MySQL Storage engine .
Its main features are :
DML Operation follows ACID Model , Support transactions ;
Row-level locks , Improve concurrent access performance ;
Support foreign keys FOREIGN KEY constraint , Ensure the integrity and correctness of data ;
The suffix of the stored disk file is .ibd,InnoDB Each table of the engine will correspond to such a tablespace file , The table structure that stores the table (frm、sdi)、 Data and index .
Parameters have innodb_file_per_table, This parameter determines whether a table corresponds to a tablespace file or multiple tables share a tablespace file .
Check the parameter code as follows :
show variables like 'innodb_file_per_table';As shown in the figure below :

You can see innodb_file_per_table The value of is ON, This means that a table corresponds to a tablespace file .
InnoDB The logical storage structure is as follows :

among :TableSpece Table space 、Segment paragraph 、Extent District ( Fixed size 1M)、Page page ( Fixed size 16k)、Row That's ok .
MyISAM
MyISAM yes MySQL Early default storage engine .
Its main characteristics are :
Unsupported transaction , Foreign key not supported ;
Support table lock , Row locks are not supported ;
Fast access .
stay MyISAM The disk space file suffixes involved are :
.MYD: Store table data ;
.MYI: Storage index ;
.sdi: Store information about the table structure .
Memory
Memory The table data of the engine is stored in memory , Due to hardware problems 、 Or the impact of power failure , These tables can only be used as temporary tables or caches .
Its main features are :
Memory storage , Fast access ;
Support hash Indexes .
Its file suffix is sdi, This file stores table structure information .
choice
Before selecting a storage engine , We first compare the characteristics of these three storage engines , The following table :
| characteristic | InnoDB | MyISAM | Memory |
|---|---|---|---|
| Storage limits | 64TB | Yes | Yes |
| Transaction security | Support | I won't support it | I won't support it |
| Locking mechanism | Row lock | Table locks | Table locks |
| B+tree Indexes | Support | Support | Support |
| Hash Indexes | I won't support it | I won't support it | Support |
| Full-text index | 5.6 Support for | Support | I won't support it |
| Space use | high | low | N/A |
| Memory usage | high | low | secondary |
| Batch insertion speed | low | high | high |
| Support foreign keys | Support | I won't support it | I won't support it |
There is no good or bad storage engine , We only need to select the appropriate storage engine according to the characteristics of the system , For complex systems , You can choose a variety of storage engines to combine according to the actual situation .
InnoDB: yes MySQL Default storage engine , Support transactions 、 Foreign keys . When applications have high requirements for transaction integrity , Data consistency is required under concurrent conditions , Data operations in addition to inserts and queries , It also contains a lot of updates 、 Delete operation , that InnoDB The storage engine is a better choice .
MyISAM: When the system is based on read operation and insert operation , There are very few update and delete operations , And the integrity of the transaction 、 Concurrency requirements are not very high , So choose MyISAM engine .
Memory: Keep all data in memory , Fast access , Usually used for temporary tables and caches .Memory The limitation of table size is the limitation of table size , Too large tables cannot be cached in memory , The security of data cannot be guaranteed .
Okay ,MySQL Advanced —— That's what the storage engine learned , Next article study MySQL Advanced —— Indexes ( Structure and classification ).
边栏推荐
- 又拍云 Redis 的改进之路
- 【Proteus仿真】数码管递加/递减带闪烁消隐显示
- isEmpty 和 isBlank 的用法区别,居然一半的人答不上来?
- SAAS服务都有哪些优势
- 我,大厂测试员,降薪50%去国企,后悔了...
- 关于组织开展2022年南京市创新产品(第一批)申报工作的通知
- Sophon autocv: help AI industrial production and realize visual intelligent perception
- Comment configurer logback? 30 minutes pour apprendre à coder et à frapper tard.
- What are the advantages of SaaS services
- 水球图-利用动态波纹展示百分比
猜你喜欢

京东方:随着下半年旺季到来、促销拉动、新产品发布等影响,需求有望出现好转

curl: (56) Recv failure: Connection reset by peer

CV5200自组网远程WiFi模组,无人机无线图传应用,高清低时延方案

又拍云 Redis 的改进之路

卫龙辣条第三次冲刺上市:业绩增速下滑,刘卫平、刘福平提前套现

Picture and text show you how to thoroughly understand the atomicity of MySQL transaction undolog

自学编程能看得懂代码,但是自己写不出来怎么办

代码大全读后感

Stable currency risk profile: are usdt and usdc safe?

After reading the complete code
随机推荐
元数据管理Apache Atlas编译集成部署及测试
The rooster Electronic Society graphical programming real questions and answers analysis of the scratch grade test level 1 June 2022
自学编程能看得懂代码,但是自己写不出来怎么办
如何配置 logback?30分钟让你彻底学会代码熬夜敲
locust性能压测工具
STM32 key chattering elimination -- Thinking of entry state machine
Stable currency risk profile: are usdt and usdc safe?
小程序在产业互联网有「大」作为
MySQL cdc jobmanager 中存了哪些比较耗内存的数据呢?
加速智能驾驶项目落地?你还缺一套真值测评系统
Science: the interrelated causes and consequences of sleep in the brain
Is it safe to open a compass account and speculate in stocks? How individuals open accounts for stock trading
DTCC2022 中国数据库技术大会最新议程出炉
[day 28] given a string s, please judge whether it is a palindrome string | palindrome judgment
或许再过两年,ASML将可以自由给中国供应EUV光刻机
Top the list for 10 consecutive years? What is the "most common" programming language for programmers?
What is the strength of a software testing engineer who can get a salary increase twice a year?
Redolog and binlog
自己实现一个ThreadLocal
Self taught programming can understand the code, but what if you can't write it yourself