Rahul Gulati
Rahul Gulati

Reputation: 363

Why does an externally stored blob need a 20 bytes pointer in MySQL?

In MySQL 5.6, I came across the following:

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.

Why does an externally stored blob require a 20-byte pointer? I don't think the address space would be so large.

Upvotes: 2

Views: 418

Answers (1)

jeremycole
jeremycole

Reputation: 2761

The data stored in-row is defined here:

https://github.com/jeremycole/mysql/blob/master/storage/innobase/include/btr0cur.h#L762

And it's written out here:

https://github.com/jeremycole/mysql/blob/master/storage/innobase/btr/btr0cur.c#L4504

So the fields written are (20 bytes total):

  • Space ID (4 bytes): Kind of redundant.
  • Page Number (4 bytes): The really important part.
  • Page Offset (4 bytes): Offset to the small header which is written within the page, also kind of redundant, since the whole page is taken.
  • Data Length (8 bytes): Length of data written externally, in total.

Upvotes: 5

Related Questions