当前位置:网站首页>Alignment HR_ MySQL storage engine, so it is
Alignment HR_ MySQL storage engine, so it is
2022-06-10 08:53:00 【Javanese aborigines, joelib】
MySQL Advanced storage engine
Thank you very much " a brand of instant noodles "
List of articles
1. first impressions are strongest
1.1 see MySQL Supported storage engines
SHOW ENGINES;

1.2 View of the default storage engine
# Method 1
SHOW VARIABLES LIKE '%storage_engine%'
# Method 2
SELECT @@SESSION.default_storage_engine;
1.3 Modify the default storage engine
# Method 1 Modify the system variable of the current session layer
SET SESSION default_storage_engine = ' Storage engine ';
# Method 2 modify my.cnf The configuration file
[mysqld]
default_storage_engine = Storage engine ;
1.4 Specify the corresponding storage engine when creating the table
CREATE TABLE IF NOT EXISTS table_name (
field_name data_type constraint,
field_name data_type constraint,
field_name data_type constraint
)engine = ' Storage engine ';
# If no storage engine is specified, the default storage engine is used Innodb
1.5 Modify the storage engine of the table
ALTER TABLE table_name engine = ' Storage engine ';
2. The introduction of storage engine
2.1 What is a storage engine
The storage engine can be understood as a table type , That is, it seems that variables have corresponding data types , Tables also have corresponding types , It's the storage engineThe storage engine determines how the table handles the data- Be careful : The above two points are based on the fact that the storage engine determines the underlying index , Indexes correspond to different data structures
2.2Innodb Storage engine
since MySQL5.5 after , The default storage engine is changed to
Innodb, The previous default storage engines wereMYISAMNo special circumstances , priority of use Innodb
InnodbIt's transactional , namelyInnodbSupport Rollback operation \InnodbIt supports foreign key constraintscommon
DML operationSuch asSELECT UPDATE DELETE INSERTShould be usedInnodbThis storage engine- The main reasons for using this engine are
MySQLYesInnodbOptimized , More efficient - Underlying index
MYISAMThe corresponding non clustered index is theoretically more efficient Later on
- The main reasons for using this engine are
File directory
MySQL8.0.ibdTable structure + Table data / Indexes ( Data is index , Index and data )
MySQL5.7.optdatabase information.frm: Table structure.ibd: Table data / Indexes ( Data is index , Index is data )
2.3MYISAM Storage engine
MYISAMNeither foreign key constraints nor transactions are supportedMYISAMThe biggest advantage is high query efficiency , It is also related to non clustered indexes- File directory
MYSQL8.0.MYDStore the data.MYIStorage index.sdiTable structure
MySQL5.7.MYDStore the data.MYIStorage index.frmTable structure.optdatabase information
2.4Innodb and MYISAM The difference between
| Contrast item | MYISAM | InnoDb | explain |
|---|---|---|---|
| Foreign keys | I won't support it | Support | |
| Business | I won't support it | Support | |
| Row table lock | Table lock | Row-level locks | With Java For example , Be similar to synchronized The role of |
| cache | Cache index only , Don't cache data | Data and indexes are cached together | The reason is also related to whether the underlying is a clustered index , therefore ,InnoDb Higher cache requirements , To a certain extent i Choose which performance |
| Use the self-contained system table | Y | N | |
| concerns | Save resources , Less consumption , Simple business | High concurrency , Business , Large amount of data | |
| Default installation | Y | Y | |
| By default | N | Y |
2.5Archive Storage engine
ArchiveIt's called archiving , As the name suggests, its main function is toArchive the data , Data archiving- because
ArchiveThe main function of is to archive , It supportsDML operationOnlySELECT & INSERToperation- among
SELECTIt's less efficient ,INSERTVery efficient
- among
2.6Blackhole Storage engine
- stay
BlackholeIn the storage engine ,INSERTOperation not allowed ,SELECTThe operation returnsNULL - therefore
DMLThe core query and insert operations are invalid , This storage engine makes no sense
2.7CSV Storage engine
CSVThe biggest highlight of the storage engine is that it generates the following file directories.CSVThis file stores the data in the table , This file can be opened by other software , Such asExceletc..CSMThis file stores the status of the table
CSVThe most important function is to visualize the tables in the database , You can open it directly with other software , Be similar toJSONandXML
2.8Memory Storage engine
MemoryThe biggest highlight of the storage engine is , Other storage engines store data on disk , andMemoryThe data is stored in memory- so
memoryIn the file directory structure under , staymysq5.7Only.frmfile , staymysql8.0There are no documents
- so
- Because the data is stored in memory
- The response speed is very fast , Query efficiency is very high
The bottom layer is the hash index , The time complexity of the query element is O(1), Even if it's B+Tree The corresponding cluster index is also O(log2N) - Data is easy to lose , Short life cycle
once mysql Service terminated , Or restart , The corresponding memory will disappear
- The response speed is very fast , Query efficiency is very high
MemoryData files and index files are stored separately , Because the bottom layer is notCluster indexMemoryThe size of is limited , Mainly depends onmax_rowsandmax_heap_table_sizemax_rowsWhen creating a table, you can specifymax_heap_table_sizeThe default is16mb, It can be increased as needed- The above two are similar to the relationship between independent variables and dependent variables
MemoryUsage scenarios of- The data is provisional , And must be used immediately , And it doesn't matter if the data is discarded
- The amount of data is relatively small , And be used frequently
- In fact, this sentence is not accurate , For the bottom layer
Hash indexIt is not suitable to do someSort , Find range valuesThe operation of
- In fact, this sentence is not accurate , For the bottom layer
Similar to the relationship between independent variable and dependent variable
MemoryUsage scenarios of- The data is provisional , And must be used immediately , And it doesn't matter if the data is discarded
- The amount of data is relatively small , And be used frequently
- In fact, this sentence is not accurate , For the bottom layer
Hash indexIt is not suitable to do someSort , Find range valuesThe operation of
- In fact, this sentence is not accurate , For the bottom layer
边栏推荐
猜你喜欢

Redis的配置优化

Take stock of the tourist attractions in Singapore

AWS IOT reference example of Lexin launching esp32-c3

vtk学习之RenderCylinder-Lights灯光渲染

乐鑫 ESP RainMaker 加速企业智能转型,私有云方案助力客户打造自有品牌

Online | 100000 bonus! Greaterwms/dvadmin plug-in developer cash incentive activities

Add cache like silk to optimize service

MMSegmention系列之六(训练技巧)

Zotero beta 6.0版本安装后,无法使用内置pdf阅读器的问题解决

MFC窗口增加状态栏的方法
随机推荐
Formula Derivation
Level 18 of leetcode Langya list - sum of two numbers (lookup table method)
对线HR_MySQL逻辑架构?就这?
Why can't Google search page infinite?
如丝般添加缓存来优化服务
一个数组对象中取出需要的多个字段以及值去掉不要的
Mmsegment Series III (basic network architecture and pre training model)
Texstudio how to compile and run tex files based on markdown macro package
The digital collection platform also said that it was "running away": its security was in doubt, and strict supervision was on the way
Task03:复杂一点的查询(二)
vscode-markdown all in one-keyboard shortcut
Task03: more complex query (2)
ifstream seekg( ) read( )文本操作
MMSegmention系列之六(训练技巧)
The R language catools package divides the data, the scale function scales the data, the KNN function of the class package constructs a k-nearest neighbor classifier, and compares the model accuracy a
RunLoop的实际使用
window11 无法打开安全中心解决方法
Test preparation computer level 2 database day 5
Vscode markdown all in One Keyboard Shortcut
Rotate linked list