Re: Please help on a question about Informix varchars
Posted in 1999
I agree with almost everything Keaton said, except for one point.
>
> > If I have a table that has 2 fields defined:
> >
> > table foo
> > problem varchar(1024) nulls allowed
> >
>
> First of all, the maximum length for a varchar is 255 characters (unless
> this is an I-Universal Server thing, which I don't have experience with
> yet).
>
> > 1. If problem is 'null', does this mean that 0 physical bytes are stored
> > for that column?
>
> If you define the column with a max length only, such as problem
> varchar(255), then the only overhead to the rowid is one byte to track
> varchar related information. So your overhead per row (indexes aside) is
> five bytes, four for the rowid and one for special varchar handling (per
> varchar column). Inserting a NULL in this case reserves zero characters, so
> zero bytes are stored for that column (except for the one byte overhead, of
> course).
Actually, if column problem is NULL, there are two bytes used - one is the length
indicator, which is set to one, and then one byte in the column's data area, which
is set to 0x0. If problem = "" (the empty string, which is different from NULL),
then the length indicator is set to zero and no bytes are stored in the column's
data area. This can be verified with 'oncheck -pp' if you wish.
Mark Collins
mcollins@us.dhl.com
Dilbert is a documentary.