mhuiyang@yahoo.com wrote:
>>
>> What document? The most detailed document (besides the source code) is
>> the internals manual: http://dev.mysql.com/doc/internals/en/index.html
>>
> http://dev.mysql.com/doc/refman/4.1/...ic-format.html
> Section 14.1.3.2. Dynamic Table Characteristics
> I checked 5.0 and 5.1 manuals and they have the same formula.
Hmm. This seems to be inaccurate at best. Could you please file
a documentation bug at
http://bugs.mysql.com ?
>> In fact there is a minumum row size of 2+2+16 = 20 bytes if you
>> use dynamic row format.
>
> I have another question: when adding a varchar column that mostly
> stores empty string (or NULL if that saves more space) does not cost
> more disk space? I guess it has to do with the existing number of
> columns and check whether it is on the verge of 8's multiple or not. It
> appears that in the worst case, adding a nullable varchar column that
> stores null or empty string will cost 1 byte per row. Am I right?
Each nullable column costs you another bit in the flags field. Since
space in the record is allocated in bytes, you can have up to 7
unused bits here. If a nullable column *is* NULL, it does not take
any additional space. However there is still the minimum length of
16 bytes for the data part. So your original table with a single,
nullable VARCHAR(64) column will yield 20 bytes/row as long as
- the column is NULL
- the column contains no more than 14 characters
HTH, XL
--
Axel Schwenke, Senior Software Developer, MySQL AB
Online User Manual:
http://dev.mysql.com/doc/refman/5.0/en/
MySQL User Forums:
http://forums.mysql.com/