对于 MyISAM 存储引擎,表默认的存储格式(storage format)为静态格式 (static format)。
当表中不包括可变长度的字段时(VARCHAR,VARBINARY,BLOB,TEXT),表中的每一行占用相同的固定长度。
一些特性:
- 固定长度的表会提高性能,因为搜寻得会更快一些,因为这些固定的长度是很容易计算下一个数据的偏移量的,所以读取的自然也会很快。
To look up a row based on a row number in the index, multiply the row number by the row length to calculate the row position. Also, when scanning a table, it is very easy to read a constant number of rows with each disk read operation.
- 更安全:
The security is evidenced if your computer crashes while the MySQL server is writing to a fixed-format MyISAM
file. In this case, myisamchk can easily determine where each row starts and ends, so it can usually reclaim all rows except the partially written one. MyISAM table indexes can always be reconstructed based on the data rows.
更容易缓存
含有 BLOB,TEXT 字段时,不使用 static format
含有CHAR,VARCHAR 字段时,可以设置为 static format。此时, 字段为自动填充内容,以保持固定长度(space-padded to the specified column width)
NULL 会占用一个 bit 的额外空间:
NULL columns require additional space in the row to record whether their values are NULL. Each NULL column takes one bit extra, rounded up to the nearest byte.
- 不需要 OPTIMIZE TABLE
Reorganization is unnecessary unless you delete a huge number of rows and want to return free disk space to the operating system.