對于 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.