当前位置:网站首页>Mysql database - storage engine
Mysql database - storage engine
2022-06-21 21:12:00 【[email protected]】
List of articles
1 MySQL Storage engine
1.1 Introduction to the concept of storage engine
MySQL The data in is stored in files with various technologies , Each technology uses a different storage mechanism 、 Indexing techniques 、 Lock levels and ultimately provide different functions and capabilities , These different technologies and supporting functions are in MySQL It's called storage engine in
The storage engine is MySQL Storage mode or storage format of data stored in file system
1.2 MySQL Common storage engines
MySQL Components in the database , Responsible for executing the actual data I/O operation
MySQL In the system , The storage engine is on top of the file system , The data is transferred to the storage engine before it is saved to the data file , Then, it is stored according to the storage format of each storage engine
1、MyISAM
2、InnoDB
1.2.1 MyISAM
1、MyISAM Characteristics
MyISAM Unsupported transaction , Foreign key constraints are not supported either , Full text indexing only , Data files and index files are kept separately
Fast access , There is no requirement for transaction integrity
MyISAM Suitable for inquiry 、 Insertion based applications
MyISAM Store three files on disk , The file name and table name are the same , But the extensions are :
.frm Definition of file storage table structure
The extension of the data file is .MYD (MYData)
The extension of the index file is .MYI (MYIndex)
Table level locking form , Lock the entire table when the data is updated
Databases block each other in the process of reading and writing :
It will block the reading of user data in the process of data writing
It will also block the user's data writing in the process of data reading
Data is written or read separately , The process is fast and takes up less resources
2、MyISAM Table support 3 Different storage formats :
(1) static state ( Fixed length ) surface
Static tables are the default storage format . Fields in static tables are immutable , So every record is a fixed length , The advantage of this storage method is that the storage is very fast , Easy to cache , It's easy to recover in case of failure ; The disadvantage is that it usually takes up more space than a dynamic table .
(2) Dynamic table
Dynamic tables contain variable fields , Records are not fixed length , The advantage of this storage is that it takes up less space , But frequent updates 、 Deleting records will cause fragmentation , It needs to be carried out on a regular basis OPTIMIZE TABLE Sentence or myisamchk -r Command to improve performance , And it's relatively difficult to recover in case of failure .
(3) Compression meter
The compressed table consists of myisamchk Tool creation , Take up a very small space , Because each record is compressed individually , So there's only a very small cost of access .
3、MyISAM Applicable production scenarios
Business doesn't need the support of business
Read or write data unilaterally
MyISAM The storage engine reads and writes data frequently, which is not suitable for the scenario
Using read-write concurrency to access relatively low business
Business with relatively little data modification
Services that do not require very high consistency of data services
The server hardware resources are relatively poor
1.2.2 InnoDB
1、InnoDB characteristic
Support transactions , Support 4 Transaction isolation levels
MySQL from 5.5.5 Version start , The default storage engine is InnoDB
Read and write blocking is related to transaction isolation level
It can cache index and data very efficiently
Tables and primary keys are stored in clusters
Support partition 、 Table space , similar oracle database
Support for foreign key constraints ,5.5 Full text indexing is not supported before ,5.5 Full text index is supported after
The requirement for hardware resources is relatively high
Row level locking , But all Table scanning will still be table level locking , Such as
update table set a=1 where user like ‘%lic%’;
InnoDB The number of rows in the table is not saved , Such as select count() from table; when ,InnoDB You need to scan the entire table to calculate how many rows there are , however MyISAM Simply read out the number of saved lines . It should be noted that , When count() The statement contains where When the conditions MyISAM You also need to scan the entire table
For self growing fields ,InnoDB Must contain only the index of this field , But in MyISAM You can create a composite index with other fields in the table
When you empty the entire table ,InnoDB It's line by line deletion , Efficiency is very slow .MyISAM The table is rebuilt
2 View storage engine
2.1 Check out the storage engines supported by the system
show engines;
2.2 Look at the storage engine that the table uses
Method 1
show table status from Library name where name=' Table name '\G;
example :show table status from SCHOOL where name='CLASS'\G;
Method 2
use Library name ;
show create table Table name ;
example :use SCHOOL;
show create table CLASS;
3 Modify the storage engine
Method 1 : adopt alter table modify
use Library name ;
alter table Table name engine=MyISAM;
example :use SCHOOL;
alter table CLASS engine=myisam;
show create table CLASS;
Method 2 : By modifying the /etc/my.cnf The configuration file , Specify the default storage engine and restart the service
quit
vim /etc/my.cnf
[mysqld]
default-storage-engine=INNODB
systemctl restart mysqld.service
# Be careful : This method only changes the configuration file and restarts mysql The newly created table is valid after service , The existing table will not be changed .
systemctl restart mysqld.service
Remember to restart after modification mysql service
# Be careful : This method only changes the configuration file and restarts mysql The newly created table is valid after service , The existing table will not be changed .
Method 3 : adopt create table Specify the storage engine when creating the table
use Library name ;
create table Table name ( Field 1 data type ,...) engine=MyISAM;
example :mysql -u root -p
use SCHOOL;
create table hellolic (name varchar(10),age char(4))engine=myisam;
版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206211932347124.html
边栏推荐
- 总结了嵌入式开发中几种常见的设备通信协议
- Introduction to internet protocol -- five layer model
- 集群一---LVS负载均衡集群NAT模式及LVS负载均衡实战部署
- 向量与平面交点
- 网关是什么
- [专利与论文-19]:江苏省南京市2022年电子信息申报通知(中、高级)
- Random forest learning notes
- Shutter tabbarview component
- What are the applications of 4.3-inch touch screen intelligent network central control host
- volatile
猜你喜欢

New hybrid architecture iformer! Flexible migration of convolution and maximum pooling to transformer

String类型转换成List<Integer>

AB打包有的Shader没有触发IPreprocessShaders的回调

What plug-ins are available for vscade?

带你区分几种并行

Take off, annual salary: 400000+

AXI_Bus_Matrix_4x4 设计 - 逻辑设计部分

集群一---LVS負載均衡集群NAT模式及LVS負載均衡實戰部署

The final scheme of adding traceid at the C end

【服务器数据恢复】EMC某型号服务器raid5数据恢复案例
随机推荐
高考后网上查询信息,注意防范没有 SSL证书的网站
volatile
Decision tree learning notes
Leecode198 looting
UIButton实现左文字右图片
Class loading process of JVM
Extend the clean, fresh and dense bag, and put a "safety lock" on the ingredients
Which futures account opening platform is good? What are the safe and regular futures companies?
Redis HyperLogLog 是什么?这些场景使用让我枪出如龙一笑破苍穹
Server body 17: simple understanding of memory mapping and shared memory
【并行与分布式计算】10b_MapReduce GFS Implementation
What is the C language callback function?
Some shaders in AB package do not trigger the callback of ipreprocessshaders
Shutter pageview component
Kubernetes-23: explain how to make CPU manager more flexible
Golang learning notes - pointer
高度可扩展,EMQX 5.0 达成 1 亿 MQTT 连接
Is it true and safe for qiniu to open a securities account? Do you charge for opening an account
集群一---LVS负载均衡集群NAT模式及LVS负载均衡实战部署
纵横网络靶场社区-Modbus协议