Static format is the default for MyISAM
tables. It is used when the table contains no variable-length
columns (VARCHAR
,
VARBINARY
,
BLOB
, or
TEXT
). Each row is stored using a
fixed number of bytes.
Of the three MyISAM
storage formats, static
format is the simplest and most secure (least subject to
corruption). It is also the fastest of the on-disk formats due
to the ease with which rows in the data file can be found on
disk: 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. Note that MyISAM
table
indexes can always be reconstructed based on the data rows.
Fixed-length row format is only available for tables without
BLOB
or
TEXT
columns. Creating a table
with these columns with an explicit
ROW_FORMAT
clause will not raise an error
or warning; the format specification will be ignored.
Static-format tables have these characteristics:
CHAR
and
VARCHAR
columns are
space-padded to the specified column width, although the
column type is not altered. This is also true for
NUMERIC
and
DECIMAL
columns created
before MySQL 5.0.3. BINARY
and VARBINARY
columns are
space-padded to the column width before MySQL 5.0.15. As of
5.0.15, BINARY
and
VARBINARY
columns are padded
with 0x00
bytes.
Very quick.
Easy to cache.
Easy to reconstruct after a crash, because rows are located in fixed positions.
Reorganization is unnecessary unless you delete a huge
number of rows and want to return free disk space to the
operating system. To do this, use
OPTIMIZE TABLE
or
myisamchk -r.
Usually require more disk space than dynamic-format tables.
User Comments
Storage space used by NULL columns:
If the table is Fixed-length the NULL coumns take up same space as they would have taken if they contained a value.
If there are lot of NULL columns and you want to save some space, then ALTER the table by adding a variable length column. That will make the table storage type as 'Dynamic' and the NULL coulmns will take up only one bit/byte.
Add your own comment.