本文主要包含:
- MySQL/
InnoDB记录的数据存储结构图.
- 对每一部分的描述.
- 示例.
在阅读了本文后, 你将了解到MySQL/InnoDB存储引擎的物理结构
存储结构
这个表格包含了innodb存储结构的三个部分.
| Name |
Size |
| Field Start Offsets |
(F*1) or (F*2) bytes |
| Extra Bytes |
6 bytes |
| Field Contents |
由存储内容而定
|
提示: 'F' 代表 字段的数量.
The meaning of the parts is as follows:
- Field Start Offsets代表了一组字段的起始位置.
- EXTRA BYTES 是固定尺寸的记录头.
- FIELD CONTENTS 存储了实际的数据.
An Important Note About The Word "Origin"
The "Origin" or "Zero Point" of a record is the first byte of the Field Contents --- not the first byte of the Field Start Offsets. If there is a pointer to a record, that pointer is pointing to the Origin. Therefore the first two parts of the record are addressed by subtracting from the pointer, and only the third part is addressed by adding to the pointer.
FIELD START OFFSETS
The Field Start Offsets is a list in which each entry is the position, relative to the Origin, of the start of the next field. The entries are in reverse order, that is, the first field's offset is at the end of the list.
An example: suppose there are three columns. The first column's length is 1, the second column's length is 2, and the third column's length is 4. In this case, the offset values are, respectively, 1, 3 (1+2), and 7 (1+2+4). Because values are reversed, a core dump of the Field Start Offsets would look like this: 07,03,01.
There are two complications for special cases:
- Complication #1: The size of each offset can be either one byte or two bytes. One-byte offsets are only usable if the total record size is less than 127. There is a flag in the "Extra Bytes" part which will tell you whether the size is one byte or two bytes.
- Complication #2: The most significant bits of an offset may contain flag values. The next two paragraphs explain what the contents are.
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
It is unlikely that the "field and offset are on different pages" unless the record contains a large BLOB.
EXTRA BYTES
阅读剩余部分...