当前位置:网站首页>MySQL brochure notes 5 InnoDB record storage structure
MySQL brochure notes 5 InnoDB record storage structure
2022-06-23 08:03:00 【morningcat2018】
MySQL Booklet notes 5 InnoDB Record storage structure
InnoDB yes MySQL The default storage engine
The speed of reading and writing to disk is very slow , And memory read and write a few orders of magnitude
Dividing data into pages , With page As an interface between disk and memory Basic unit ,InnoDB The size of the middle page is generally 16 KB.
That is to say, in general , Read at least from disk at a time 16KB In memory , Put at least... In memory at a time 16KB Refresh content to disk .
- We usually use
RecordUnit to insert data into the table , The way these records are stored on disk is also calledLine formatperhapsRecord format.
4 A common row format is Compact、Redundant、Dynamic and Compressed Line format .
- Specify the row format
CREATE TABLE Table name ( Column information ) ROW_FORMAT= Line format name ;
ALTER TABLE Table name ROW_FORMAT= Line format name ;
CREATE TABLE record_format_demo (
c1 VARCHAR(10),
c2 VARCHAR(10) NOT NULL,
c3 CHAR(10),
c4 VARCHAR(10)
) CHARSET=ascii ROW_FORMAT=COMPACT;
INSERT INTO record_format_demo(c1, c2, c3, c4) VALUES('aaaa', 'bbb', 'cc', 'morningcat2018'), ('eeee', 'fff', NULL, NULL);
+------+-----+------+---------------------+
| c1 | c2 | c3 | c4 |
+------+-----+------+---------------------+
| aaaa | bbb | cc | morningcat2018 |
| eeee | fff | NULL | NULL |
+------+-----+------+---------------------+
- Compact Line format
- Additional information recorded
- Variable length field length list
- MySQL Support some variable length data types , such as VARCHAR(M)、VARBINARY(M)、 Various TEXT type , Various BLOB type ; Columns of these data types are called
Variable length field - The storage space occupied by these variable length fields is divided into two parts :1 Real data content ,2 Number of bytes occupied
- The number of bytes occupied by the variable length field data is in the order of columns
Storage in reverse order- In the first record c1、c2、c4 Columns are variable length fields , The lengths are 4,2,14 ; therefore
Variable length field length listThe value of is0E0204( Hexadecimal representation ) - In the second record c4 by NULL Don't record ; therefore
Variable length field length listThe value of is0304
- In the first record c1、c2、c4 Columns are variable length fields , The lengths are 4,2,14 ; therefore
- MySQL Support some variable length data types , such as VARCHAR(M)、VARBINARY(M)、 Various TEXT type , Various BLOB type ; Columns of these data types are called
- NULL List of values
- Use 1bit Storage ,1 The value representing the column is NULL;0 The value representing the column is not NULL
- Storage in reverse order
- Zero up for high position
- Only possible NULL Columns of are stored here ; therefore record_format_demo Tabular
NULL List of valuesby 0000 0 c4 c3 c1- In the second record ,c3 c4 by NULL, The value is 1 ; therefore
NULL List of valuesby 0000 0110 ; Hexadecimal is expressed as06
- In the second record ,c3 c4 by NULL, The value is 1 ; therefore
- Record header information
- fixed
5 Bytesform (40 bit)- reserved 1 1bit
- reserved 2 1bit
- delete_mask 1bit Mark whether the record is deleted
- min_rec_mask 1bit B+ This flag is added to the minimum record in each non leaf node of the tree
- n_owned 4bit Indicates the number of records owned by the current record
- heap_no 13bit Represents the location information of the current record in the record heap
- record_type 3bit Indicates the type of current record ,0 It means ordinary record ,1 Express B+ Tree non leaf node records ,2 Represents the minimum record ,3 Indicates the maximum record
- next_record 16bit Indicates the relative position of the next record
- fixed
- Variable length field length list
- Real data recorded
- In addition to custom column data ,MySQL Some columns will be added by default for each record ( Also known as
Hide columns)- DB_ROW_ID Not necessary 6byte That's ok ID, Uniquely identify a record
- DB_TRX_ID must 6byte Business ID
- DB_ROLL_PTR must 7byte rollback pointer
- InnoDB Table generation strategy for primary key
- User defined primary key is preferred
- No primary key defined , Then choose one Unique Key as primary key
- even Unique If there's no definition of a key , be InnoDB A table named... Is added by default row_id As the primary key
- The first 1 In records
- c3 The value of the column , It is CHAR(10) Type of , The string it actually stores is :‘cc’, and ascii The byte representation in the character set is ’0x6363’, Although it means that this string only takes 2 Bytes , But the whole c3 Columns still occupy 10 Bytes of space ,
- Other than real data 8 All bytes are filled with space characters , The space character is in ascii The representation of a character set is 0x20
- In addition to custom column data ,MySQL Some columns will be added by default for each record ( Also known as
- Redundant Line format
Redundant The line format is MySQL5.0 A line format used before
- line overflow
A page is usually 16KB, When there is too much data in the record , When the current page doesn't fit , The extra data will be stored in other pages , This phenomenon is called line overflow
边栏推荐
- Unity to wechat applet games
- 快速排序 + 冒泡排序 + 插入排序 + 選擇排序
- Playwirght深度入门
- @Controller和@RestController的区别?
- openni.utils.OpenNIError: (OniStatus.ONI_STATUS_ERROR, b‘DeviceOpen using default: no devices found‘
- [try to hack] IP address
- 生产环境服务器环境搭建+项目发布流程
- 快速删除代码里面的node_modules
- C# scrollView 向上滚动还是向下滚动
- 快速排序 + 冒泡排序 + 插入排序 + 选择排序
猜你喜欢

1278_ FreeRTOS_ Understand the delayed task with the prvaddcurrenttasktodelayedlist interface

Talk about routing design in service governance

Qt 使用QDomDocument读取xml文件

Playwirght深度入门

Ad object of Active Directory

1278_FreeRTOS_借助prvAddCurrentTaskToDelayedList接口理解delayed task

Interview questions of a company in a certain month of a certain year (1)

Rotary table visual screening machine and its image recognition system

MIT CMS.300 Session 12 – IDENTITY CONSTRUCTION 虚拟世界中身份认同的建立 part 2

transform的结构及用法
随机推荐
华为云服务器弹性公网IP无法ping
Distributed ID generation
Ignore overlength parameter violation
openvino系列 19. OpenVINO 与 PaddleOCR 实现视频实时OCR处理
Active Directory之AD对象
transform的结构及用法
Match 56 de la semaine d'acwing [terminé]
Using jetpack datastore for data storage
2. probability theory - axiom of probability theory
odoo项目 发送信息到微信公众号或企业微信的做法
Acwing第 56 场周赛【完结】
Playwirght getting started
qt 不规则图形 消除锯齿
Location of firewalld configuration file
MySQL gets the system time period
Socket programming (multi process)
Apache Solr 任意文件读取复现
Matlab随机波动率SV、GARCH用MCMC马尔可夫链蒙特卡罗方法分析汇率时间序列
数学知识:快速幂—快速幂
socket编程(多线程)