当前位置:网站首页>The difference and implementation of MyISAM and InnoDB in MySQL
The difference and implementation of MyISAM and InnoDB in MySQL
2022-07-22 08:28:00 【Dried bamboo shoots zzz~】
Mysql in MyISAM and InnoDB The difference and implementation of :
difference :
- InnoDB Support transactions ,MyISAM Unsupported transaction . This is a MySQL Set the default storage engine from MyISAM become InnoDB One of the important reasons .
- InnoDB Support foreign keys , and MyISAM I won't support it . For one containing a foreign key InnoDB Table to MyISAM Will fail .
- InnoDB The smallest lock granularity is row locks ,MyISAM The smallest lock granularity is table locks . An update statement locks the entire table , As a result, other queries and updates will be blocked , So concurrent access is limited .
- Execute a lot of select,MyISAM Is the best choice ; Perform a lot of update and insert It is best to InnoDB. InnoDB Do not save the specific rows of the table , perform select count(*) from table You need a full scan . and MyISAM A variable is used to save the number of rows in the whole table , You only need to read the variable when executing the query statement , fast .
- MyISAM There are three files stored on disk .frm( Storage table definition ) .myd( Store table data ) .myi( Storage table index ); InnoDB What is stored on disk are tablespace data files and log files ,innodb The size of the table is limited only by the size of the operating system .
- delete from table when , InnoDB Will be deleted line by line .
- MyISAM Use nonclustered indexes , Index and data are separated , Cache index only ,InnoDB Using a clustered index , Index and data exist in a file .
Query implementation :
MyISAM:
This index is created by B+ Trees make up , When executing the query operation, you will first check B+ Query the tree , If the corresponding leaf node is found , Then the value of the leaf node will be taken ( Address ), Find the whole line of data through the address .
Innodb
When searching the main index
The picture below is Innodb Schematic diagram of main index lookup , It can be seen that the leaf node contains complete data records , This indexing method is called clustered indexing . because InnoDB The data file itself is aggregated according to the primary key , Indexes InnoDB The table must have a primary key (MyISAM There can be no ), If not specified , be MySQL The system will automatically select a column that can uniquely identify the data record as the primary key , If there is no such column , be MySQL Automatically for InnoDB Table generates an implicit field as the primary key , Type is long long The length of this field is 6 Bytes .
Secondary index search
It's in English ASCII Code as a comparison criterion . The implementation of clustered index makes the search by primary key very efficient , But the secondary index search needs to retrieve the index twice : First retrieve the secondary index to get the primary key , Then use the primary key to retrieve the record in the primary index .
边栏推荐
- 云安全日报220721:思科混合云运维管理解决方案发现执行任意命令漏洞,需要尽快升级
- YouTube subtitle download
- Redis的经典三问以及哨兵
- Explain pytorch visualization tool visdom in detail (I)
- Percona XtraDB Cluster安装
- IDEA 如何自动导入(import)
- 华泰证券账户开户安全吗,手机上就可以办理的吗?
- R language uses the ggarrange function of ggpubr package to combine multiple images, and uses the ggexport function to save the visual image in TIFF format (width parameter specifies width, height par
- 自学golang【3.6切片slice的练习代码】切片的长度,上限,复制,删除与增加
- R language uses LM function to build multiple linear regression model and build regression model without intercept term (the model does not contain intercept)
猜你喜欢
随机推荐
Make sure your hardware is connected stably before coding!!!
Linux(Centos)安装Mysql
MySQL存储过程
数据分析与挖掘2
Detailed explanation of ternary operators in JS
SPI debugging is not successful, it is likely that you connected the wrong cable!!
excel 隐藏和取消隐藏
AttributeError:module ‘distutils’ has no attribute ‘version错误解决方法
Error: L6218E: Undefined symbol SX1276FskGetPacketCrcOn (referred from sx1276-fsk.o)
How excel automatically matches gender code according to ID number
Generating function (linear recursive relationship, generating function concept and formula derivation, violent calculation) 4000 word detailed analysis, with examples
Physical address introduction "recommended collection"
存储容量与地址空间的计算
Percona XtraDB Cluster安装
STM32 SPI 读取数据不准确,只有第一次对,后边均不对
C中如何打开stdio.h ? 如何找到printf的定义?
EXCEL一些技巧
CDH 6.1 environment construction graphic tutorial
WebSockets 和 Server-Sent Events
R language tests the significance of correlation coefficient: use cor.test function to calculate the value and confidence interval of correlation coefficient and its statistical significance (if the v