When a row is too long, the longest columns are chosen for off-page storage until the clustered index record fits on the B-tree page.

MySQL :: MySQL 8.0 Reference Manual :: 15.10 InnoDB Row Formats https://dev.mysql.com/doc/refman/8.0/en/innodb-row-format.html

 

When a table is created with ROW_FORMAT=DYNAMICInnoDB can store long variable-length column values (for VARCHARVARBINARY, and BLOB and TEXT types) fully off-page, with the clustered index record containing only a 20-byte pointer to the overflow page. Fixed-length fields greater than or equal to 768 bytes are encoded as variable-length fields. For example, a CHAR(255) column can exceed 768 bytes if the maximum byte length of the character set is greater than 3, as it is with utf8mb4.

Whether columns are stored off-page depends on the page size and the total size of the row. When a row is too long, the longest columns are chosen for off-page storage until the clustered index record fits on the B-tree page. TEXT and BLOB columns that are less than or equal to 40 bytes are stored in line.

The DYNAMIC row format maintains the efficiency of storing the entire row in the index node if it fits (as do the COMPACT and REDUNDANT formats), but the DYNAMIC row format avoids the problem of filling B-tree nodes with a large number of data bytes of long columns. The DYNAMIC row format is based on the idea that if a portion of a long data value is stored off-page, it is usually most efficient to store the entire value off-page. With DYNAMIC format, shorter columns are likely to remain in the B-tree node, minimizing the number of overflow pages required for a given row.

 

posted @ 2022-01-27 09:46  papering  阅读(66)  评论(0编辑  收藏  举报