Subject Re: [firebird-support] CHAR Vs VARCHAR vs Smallint for storing int value from 0 to 255
Author Ann W. Harrison
I wrote

> CHAR(1) stores between 0 and 2 bytes on disk, depending on what
> comes near it. Before storing bytes on disk, Firebird does a
> run length compression, adding count bytes. A positive <n> count
> byte means that the next <n> bytes appear in the string as they
> appear on disk - thus four CHAR(1) fields with values of 1, 2, 3,
> & 4 will appear as 4, 1, 2, 3, 4.

Five CHAR(1) fields with values of 1, 2, 3, 4, 5 appear as
5, 1, 2, 3, 4, 5 - adding one more field adds one more byte
to the stored size.

> A negative <n> count means
> that the next value appears n * -1 times. Four CHAR(1) field that
> all have the value 3 will appear as -4, 3.

Five CHAR(1) fields containing the value 2 appear as -5, 3, so the
extra field adds nothing to the stored length.


Cheers,

Ann