The difference really matters only to MyISAM, other storage engines don't care about the difference. UPDATE: Many users have noted that InnoDB really cares: link 1 - , link 2 - Kaan .
With MyISAM with fixed line widths, there are several advantages:
No line fragmentation: using variable-width lines, you can split individual lines into several sections in the data file. This can increase disk search and slow down performance. It can be defragmented with OPTIMIZE TABLE, but this is not always practical.
Size of a pointer to a data file: MyISAM has the concept of a pointer to a data file, which is used when it needs to access a data file. For example, this is used in indexes when they refer to where the string is actually present. For fixed widths, this pointer is based on the offset of lines in the file (i.e. lines are 1, 2, 3 regardless of their size). With a variable width, the pointer is based on a byte offset (i.e. strings can be 1, 57, 163). As a result, the pointer should be larger for large tables, which potentially adds a lot more overhead to the table.
Easier to fix in case of corruption. Since each row is the same size, if your MyISAM table is corrupted, it is much easier to repair, so you only lose the data that is really corrupted. With variable widths, it is theoretically possible that variable-width pointers will get corrupted, which can lead to incorrect data transfers.
Now the main disadvantage of fixed widths is that it spends more space. For example, you need to use CHAR fields instead of VARCHAR fields so that additional space is eventually taken up.
As a rule, you will not have much choice in the format, as it is dictated by the scheme. However, this can be useful if you only have a few varchar or one blob / text to try to optimize this. For example, consider switching a single varchar to a character, or split a blob into its own table.
You can read more about this at:
http://dev.mysql.com/doc/refman/5.0/en/static-format.html
http://dev.mysql.com/doc/refman/5.0/en/dynamic-format.html
Harrison Fisk Sep 29 '08 at 2:37 2008-09-29 02:37
source share