mysql innodb行格式

redundant行记录格式:

PHYSICAL RECORD (OLD STYLE)

The physical record, which is the data type of all the records
found in index pages of the database, has the following format
(lower addresses and more significant bits inside a byte are below
represented on a higher text line):

| offset of the end of the last field of data, the most significant
bit is set to 1 if and only if the field is SQL-null,
if the offset is 2-byte, then the second most significant
bit is set to 1 if the field is stored on another page:
mostly this will occur in the case of big BLOB fields |

| offset of the end of the first field of data + the SQL-null bit |
| 4 bits used to delete mark a record, and mark a predefined
minimum record in alphabetical order |
| 4 bits giving the number of records owned by this record
(this term is explained in page0page.h) |
| 13 bits giving the order number of this record in the
heap of the index page |
| 10 bits giving the number of fields in this record |
| 1 bit which is set to 1 if the offsets above are given in
one byte format, 0 if in two byte format |
| two bytes giving an absolute pointer to the next record in the page |
ORIGIN of the record
| first field of data |

| last field of data |

1)Field Start Offsets:字段数1字节或字段数2字节,一组列表,存储字段数据的偏移,该列表中第一个值表示最后一个字段的偏移,最后一个值表示第一个字段的偏移

When The Size Of Each Offset Is One Byte
1 bit = NULL, = NULL
7 bits = the actual offset, a number between 0 and 127
When The Size Of Each Offset Is Two Bytes
1 bit = NULL, = NULL
1 bit = 0 if field is on same page as offset, = 1 if field and offset are on different pages
14 bits = the actual offset, a number between 0 and 16383

2)Extra Bytes:6字节,各bit描述如下:

NameSize (bit)Description
()1 bitunused or unknown
()1 bitunused or unknown
deleted_flag1 bit1 if record is deleted
min_rec_flag1 bit1 if record is predefined minimum record
n_owned4 bitsnumber of records owned by this record
heap_no13 bitsrecord’s order number in heap of index page
n_fields10 bitsnumber of fields in this record, 1 to 1023,the number of fields is by definition equal to the number of entries in the Field Start Offsets Table
1byte_offs_flag1 bit1 if each Field Start Offsets is 1 byte long (this item is also called the “short” flag)
next 16 bits16 bitspointer to next record in page

3)Field Contents:实际数据内容,注意innodb所有表会自动创建3个系统字段,分别存储rowID,transactionID,rollback pointer

compact/dynamic行格式记录

PHYSICAL RECORD (NEW STYLE)

The physical record, which is the data type of all the records
found in index pages of the database, has the following format
(lower addresses and more significant bits inside a byte are below
represented on a higher text line):

| length of the last non-null variable-length field of data: 最后一个非空可变长度字段数据的长度
if the maximum length is 255, one byte; otherwise, 如果字段的长度小于等于255字节,在该字段列表中则占1字节
0xxxxxxx (one byte, length=0…127), or 1exxxxxxxxxxxxxx (two bytes,如果字段的长度大小大于255字节,对于0…127的实际数据长度在该列表占用1字节,
length=128…16383, extern storage flag) | 对于127字节以上的实际数据长度在该字段列表中占2字节(len & 0x80为真表示占用2字节),或者外部存储(因此这里存放一个外部存储标志len & 0x40为真表示外部存储)
注意:1exxxxxxxxxxxxxx中的位e表示extern flag,当此位为1表示外部存储标志,位xxxxxxxxxxxxxx表示实际长度,位1表示数据长度大于127字节
… 倒数第二个非空可变长度字段数据的长度…
| length of first variable-length field of data | 第一个非空可变长度字段数据的长度
| SQL-null flags (1 bit per nullable field), padded to full bytes | NULL标记位,可变,占用字节数不明,还需要分析,表示该行是否有空值
| 4 bits used to delete mark a record, and mark a predefined
minimum record in alphabetical order |
| 4 bits giving the number of records owned by this record
(this term is explained in page0page.h) |
| 13 bits giving the order number of this record in the
heap of the index page |
| 3 bits record type: 000=conventional, 001=node pointer (inside B-tree),
010=infimum, 011=supremum, 1xx=reserved |
| two bytes giving a relative pointer to the next record in the page |
ORIGIN of the record
| first field of data |

| last field of data |

1)变长字段长度列表:如果列的长度小于255字节,用1字节表示;如果大于255个字节,用2字节表示,该列表中最后一个值表示第一个字段数据长度,第一个值表示最后一个字段数据长度
2)NULL标志位:表明该行数据是否有NULL值。可变,表示该行是否有空值,占用字节数不明,还需要分析,目前的分析结果是如果第一行有9个字段为空,则占2字节,以后插入的即使只有一个字段为空也占2字节
3)Extra Bytes:固定占用5字节,每位的含义见下表:

名称大小(bit)描述
()1未知
()1未知
delete_flag1该行是否已被删除
min_rec_flag1为1,如果该记录是预先被定义为最小的记录
n_owned4该记录拥有的记录数
heap_no13索引堆中该记录的排序记录
record_type3记录类型,000表示普通,001表示B+树节点指针,010表示infimum,011表示supermum,1xx表示保留
next_record16页中下一条记录的相对位置

4)Field Contents:实际数据内容,注意innodb所有表会自动创建3个系统字段,分别存储rowID,transactionID,rollback pointer

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值