Subject | Re: [firebird-support] Varchar - NULL vs blank |
---|---|
Author | Ann W. Harrison |
Post date | 2006-10-18T22:25:48Z |
Rick Debay wrote:
filled, then subjected to run-length compression. Both start with
two bytes of zero. The only slight difference is that at the
beginning of the record there's a string of bytes which represent
the null flags. A record with 14 columns will have two bytes of
null flags. If the fourth field is null, the fourth bit of the
first byte will be set. The null bytes are also subject to run
length compression. If none of the fields are null, then the
null bytes are all zeros and compressible. That's a really small
difference.
Regards,
Ann
Run length compression works like this. First there's a byte.
If its positive, it's followed by that many bytes of data. If
it's negative, it's followed by one byte to be repeated -1
multiplied by that number of times. For example, this string
of bytes 3, 'a', 'b', 'c', -4, 'd' represents this string:
'abcdddd'. A 100 byte null varchar would be represented
(probably, depending on what preceded and followed it) as
2, 0, 0, -100, ' '. The compression is done on row as a
whole, not field by field.
>For storage, an empty varchar and a null varchar are both blank
> In this case I really need to know if there is a difference in the
> storage requirements.
filled, then subjected to run-length compression. Both start with
two bytes of zero. The only slight difference is that at the
beginning of the record there's a string of bytes which represent
the null flags. A record with 14 columns will have two bytes of
null flags. If the fourth field is null, the fourth bit of the
first byte will be set. The null bytes are also subject to run
length compression. If none of the fields are null, then the
null bytes are all zeros and compressible. That's a really small
difference.
Regards,
Ann
Run length compression works like this. First there's a byte.
If its positive, it's followed by that many bytes of data. If
it's negative, it's followed by one byte to be repeated -1
multiplied by that number of times. For example, this string
of bytes 3, 'a', 'b', 'c', -4, 'd' represents this string:
'abcdddd'. A 100 byte null varchar would be represented
(probably, depending on what preceded and followed it) as
2, 0, 0, -100, ' '. The compression is done on row as a
whole, not field by field.