理解 MySQL MyISAM ROW_FORMAT=DYNAMIC

Understanding MySQL MyISAM ROW_FORMAT=DYNAMIC

我有一个 MyISAM table,只有 1600 列整数类型(tinyint、smallint、mediumint、int)。 table 有 80 万行。

ROW_FORMAT=FIXED => 二进制文件大小 = 3GB(= 预期值)

ROW_FORMAT=DYNAMIC => 二进制文件大小 = 200MB

为什么文件大小会改变,因为所有列 (请不要问我列数) 的长度是固定的?

零值以动态格式优化。来自 documentation:

Each row is preceded by a bitmap that indicates which columns contain the empty string (for string columns) or zero (for numeric columns). This does not include columns that contain NULL values. If a string column has a length of zero after trailing space removal, or a numeric column has a value of zero, it is marked in the bitmap and not saved to disk. Nonempty strings are saved as a length byte plus the string contents.

所以大小差异表明您 table 中的大部分值都是零。