Subject Re: [firebird-support] Varchar size overhead
Author Ivan Prenosil
"Ann W. Harrison" wrote:
>>> 2.) 127 ->2 (from a friend)
>>> 3.) 128 -> 2 (Ivan)
>>> 4.) 256 -> 2 (Ann Harrison, message below),
...
> When a record is stored, it is first buffered at its full
> declared length - meaning that a varchar 1000 used 1002
> bytes, a char 1000 uses 1000 bytes, a double uses 8 bytes,
> etc.
>
> Then firebird does run length compression on that buffer.
> The first byte is a count. If it's positive <n>, it means
> that the next <n> bytes are part of the record. If negative,
> it means that the next byte is to be replicated <n * -1>
> times.
>
> Thus the string "abcddddef" becomes <3>abc<-4>d<2>ef

And the range of values in one signed byte is -128..127,
thus allowing to compress up to 128 same bytes into two.

(can "-1" be used as repeat count ??)

Ivan