当前位置:网站首页>存储引擎分析
存储引擎分析
2022-06-30 01:02:00 【华为云】
存储引擎
MySQL体系结构:


存储引擎就是存储数据、建立索引、更新/查询数据等技术的实现方式。存储引擎是基于表而不是基于库的,所以存储引擎也可以被称为表引擎。默认存储引擎是InnoDB。
相关操作:
-- 查询建表语句show create table account;-- 建表时指定存储引擎CREATE TABLE 表名( ...) ENGINE=INNODB;-- 查看当前数据库支持的存储引擎show engines;InnoDB
InnoDB 是一种兼顾高可靠性和高性能的通用存储引擎,在 MySQL 5.5 之后,InnoDB 是默认的 MySQL 引擎。
特点:
- DML 操作遵循 ACID 模型,支持事务
- 行级锁,提高并发访问性能
- 支持外键约束,保证数据的完整性和正确性
文件:
- xxx.ibd: xxx代表表名,InnoDB 引擎的每张表都会对应这样一个表空间文件,存储该表的表结构(frm、sdi)、数据和索引。
参数:innodb_file_per_table,决定多张表共享一个表空间还是每张表对应一个表空间
知识点:
查看 Mysql 变量:show variables like 'innodb_file_per_table';
从idb文件提取表结构数据:(在cmd运行)ibd2sdi xxx.ibd
InnoDB 逻辑存储结构:

MyISAM
MyISAM 是 MySQL 早期的默认存储引擎。
特点:
- 不支持事务,不支持外键
- 支持表锁,不支持行锁
- 访问速度快
文件:
- xxx.sdi: 存储表结构信息
- xxx.MYD: 存储数据
- xxx.MYI: 存储索引
Memory
Memory 引擎的表数据是存储在内存中的,受硬件问题、断电问题的影响,只能将这些表作为临时表或缓存使用。
特点:
- 存放在内存中,速度快
- hash索引(默认)
文件:
- xxx.sdi: 存储表结构信息
存储引擎特点
存储引擎的选择
在选择存储引擎时,应该根据应用系统的特点选择合适的存储引擎。对于复杂的应用系统,还可以根据实际情况选择多种存储引擎进行组合。
- InnoDB: 如果应用对事物的完整性有比较高的要求,在并发条件下要求数据的一致性,数据操作除了插入和查询之外,还包含很多的更新、删除操作,则 InnoDB 是比较合适的选择
- MyISAM: 如果应用是以读操作和插入操作为主,只有很少的更新和删除操作,并且对事务的完整性、并发性要求不高,那这个存储引擎是非常合适的。
- Memory: 将所有数据保存在内存中,访问速度快,通常用于临时表及缓存。Memory 的缺陷是对表的大小有限制,太大的表无法缓存在内存中,而且无法保障数据的安全性
电商中的足迹和评论适合使用 MyISAM 引擎,缓存适合使用 Memory 引擎。
边栏推荐
- RubyMine开发工具,重构和意图操作
- In depth analysis of a large number of clos on the server_ The root of wait
- [mrctf2020]ezpop-1 | PHP serialization
- Yunna | advantages of fixed assets system management, what are the characteristics of fixed assets management system
- Shell spec date format
- 字节面试惨遭滑铁卢:一面就被吊打,幸得华为内推,三面拿到offer
- [Simulation Proteus] détection de port 8 bits 8 touches indépendantes
- In 2022, the latest and most detailed idea associated database method and visual operation of database in idea (including graphic process)
- 【three.js】WEB3D初次体验
- 眼底出血术后需注意事项//每天必看
猜你喜欢

月薪没到30K的程序员必须要背的面试八股,我先啃为敬!

眼底出血术后需注意事项//每天必看

Antd - tree structure: default deployment node attribute failure - Basic promotion

How to design test cases

阿于的彩虹桥

2022 6 月25 日交易总结

Yunna | advantages of fixed assets system management, what are the characteristics of fixed assets management system

The listing of Symantec electronic sprint technology innovation board: it plans to raise 623million yuan, with a total of 64 patent applications

A Yu's Rainbow Bridge

Vl6180x distance and light sensor hands-on experience
随机推荐
Live broadcast configuration of crmeb knowledge payment system program configuration (method 2)
Seata 與三大平臺攜手編程之夏,百萬獎金等你來拿
[mrctf2020]ezpop-1 | PHP serialization
如何在IDEA中创建Module、以及怎样在IDEA中删除Module?
田口实验法
如何在IDEA中自定義模板、快速生成完整的代碼?
英伟达Jetson Nano的初步了解
Nested call and chained access of functions in handwritten C language
Clean, talk, bring children, and get rid of the label of "artificial mental retardation" for the sweeper
[concurrent programming] if you use channel to solve concurrency problems?
[lorawan node application] the application and power consumption of Anxin ra-08/ra-08h module in lorawan network
月薪没到30K的程序员必须要背的面试八股,我先啃为敬!
在线SQL转CSV工具
How to customize templates and quickly generate complete code in idea?
Text classification using huggingface
开发者,为什么说容器技术的成熟预示着云原生时代的到来?
Interviewer: how to solve the problem of massive requests for data that does not exist in redis, which affects the database?
Cantilever beam calculation [matlab code]
Analysis of IM instant messaging development technology on modern web
DL: deep learning model optimization model training skills summary timely automatic adjustment of learning rate implementation code