在 MySQL 5.6 中,我遇到了以下问题:
For tables created in ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED, the values of BLOB, TEXT or VARCHAR columns may be stored fully off-page, depending on their length and the length of the entire row. For columns that are stored off-page, the clustered index record only contains 20-byte pointers to the overflow pages, one per column.
为什么外部存储的 blob 需要 20 字节的指针?我不认为地址空间会这么大。
最佳答案
行内存储的数据定义如下:
https://github.com/jeremycole/mysql/blob/master/storage/innobase/include/btr0cur.h#L762
它写在这里:
https://github.com/jeremycole/mysql/blob/master/storage/innobase/btr/btr0cur.c#L4504
因此写入的字段为(总共 20 个字节):
- 空间 ID(4 字节):有点多余。
- 页码(4 字节):非常重要的部分。
- 页面偏移(4 个字节):页面内写入的小 header 的偏移量,也有点多余,因为整个页面都会被占用。
- 数据长度(8字节):外部写入数据的总长度。
关于mysql - 为什么 MySQL 中外部存储的 blob 需要 20 字节的指针?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16845293/