当前位置:网站首页>MySQL series: storage engine
MySQL series: storage engine
2022-06-23 15:24:00 【yue_ xin_ tech】
Introduce
In the last article mysql General overview We probably know mysql Architecture design , It says Storage engine . It's in mysql Is a very important role in , Responsible for the creation of data 、 Read and update , That's the data I/O operation .
most important of all , It is Pluggable Module , This means that when we switch storage engines , For upper layer applications , There is no need to do any adaptation .
There are many kinds of storage engines , And they all have their own characteristics , Like the usual InnoDB Have transaction support 、MyISAM Fast, etc .
Usage of storage engine
As a plug-in module , We can naturally add 、 Uninstall the storage engine , And specify the storage engine when creating the table .
Load the storage engine
mysql Through defined API Interface to communicate with the storage engine , So we just need to implement the corresponding API Interface , You can go to mysql Load in at run time .
stay mysql There is one in the source code example Storage engine for , We can see what it needs to achieve API The interface is as follows :

When we implement these methods , You can compile it into a shared library , Then load it in with the following statement
INSTALL PLUGIN example SONAME 'example.so';
It should be noted that , The plug-in file must be located in mysql Plug in directory , And have the right to plugin Tabular INSERT jurisdiction .
Uninstall the storage engine
To uninstall the storage engine , It's simpler
UNINSTALL PLUGIN example;
When uninstalled , The corresponding table will inaccessible , So be sure to pay attention to whether there are still tables of the storage engine in use !
View and use the storage engine
When we load the storage engine , You can use the following command to view :
show engines;
If we want to use the corresponding storage engine , You can use the following method :
- Specify... When creating a table :CREATE TABLE t1 (id INT) ENGINE = INNODB;
- Set default usage :SET default_storage_engine=INNODB;
- Specify when modifying a table :ALTER TABLE t ENGINE = InnoDB;
among ALTER TABLE The old table will be copied to the new table , And it will be locked during this period , Pay special attention to .
Types and characteristics of storage engines
stay mysql There are many kinds of storage engines implemented in , Each storage engine has its own characteristics . Let's see mysql What are the supported storage engines in .
InnoDB: It is mysql The default storage engine for , Can achieve ACID Characteristic transactions , And can submit 、 Roll back 、 Restore data , It can well protect user data . Row level locks are also supported 、 Clustered indexes and foreign key constraints , Is a perfect storage engine .
MyISAM: yes mysql The initial storage engine , Small footprint , Can quickly store , Transaction is not supported , Provides lock granularity based on table level , For applications with configuration or read-only functionality .
Memory: The data is stored in memory , Can provide fast access , However, fewer people should use , After all, once the power is off, the data will be lost .
CSV: Text file with comma separated values , No index exists . But the compatibility is very good , You can exchange data with other programs .
Other storage engines use less , I won't mention ,
Differences between storage engines
Storage engines have their own characteristics , Their differences can be roughly summarized as follows :
concurrency: The granularity control of locks is different , Some provide table locks , Some provide row locks , Some even provide snapshot reading .Business: Some storage engines support , Some don't support , Not every program design requires transactions , Pipelined data such as logs is not needed .Referential integrity: That is, whether foreign keys are supported , With foreign keys , It is highly correlated , Association check will be performed when deleting .storage: The storage methods of tables and indexes are different , image MyISAM Will be stored in three files ,InnoDB All tables are stored in the same data file .Index support: There are clustered indexes , Store data directly on the leaf node , Some leaf nodes only store pointers to data areas .
summary
The plug-in storage engine brings us a variety of options , There are no rules for which storage engine to use , It can only be selected according to the current demand analysis . Like you want a full-text index , You can choose MyISAM or InnoDB, Want data integrity or transaction support , You need to choose InnoDB.
Of course , Many times, we will directly choose the default storage engine InnoDB, After all, in the face of Internet projects that will change their needs at any time , Big and full is our best choice .
Interested friends can search the official account 「 Read new technology 」, Pay attention to more push articles .
If you can , Just like it by the way 、 Leave a message 、 Under the share , Thank you for your support !
Read new technology , Read more new knowledge .
边栏推荐
猜你喜欢

golang 重要知识:sync.Cond 机制

2021-05-22

进销存软件排行榜前十名!

golang 重要知识:RWMutex 读写锁分析

基因检测,如何帮助患者对抗疾病?

30. 串联所有单词的子串

The "shoulder" of sales and service in the heavy truck industry, Linyi Guangshun deep ploughing product life cycle service

2021-05-08

Summary of operating system underlying knowledge (interview)

2021-05-22
随机推荐
Print memory station information
[普通物理] 光的衍射
idea查看.class文件 idea查看.class文件夹
Half wave loss equal thickness and equal inclination interference
2021-04-15
2021-06-03
When I went to oppo for an interview, I got numb...
How can genetic testing help patients fight disease?
Convert JSON file of labelme to coco dataset format
[datahub] LinkedIn datahub learning notes
K8s-- deploy stand-alone MySQL and persist it
JSR303数据校验
Analysis and solution of connection failure caused by MySQL using replicationconnection
mysql主从只同步部分库或表的思路与方法
32. Compose 优美的触摸动画
Mysql双主配置的详细步骤
Introduction to the push function in JS
【云驻共创】制造业企业如何建设“条码工厂”
详解Redis分布式锁的原理与实现
Xampp中mysql无法启动问题的解决方法