Re: Size of varchar
Posted in 1998
The Wilcoxons wrote: > Tom Grenier wrote in message <361AA3C7.9D87A721@biztravel.com>... > >If I have a varchar that the developers are not sure how large it will > >be -- they guess 50-100 chars but may grow later -- and is not going to > >be indexed -- is there any reason *not* to create it as a varchar(255)? > >From all I can read there is no more overhead or space taken with a > >varchar(255) where all data are less then 100 chars than defining it as > >a varchar(100). > > > >Am I overlooking something? > > > >TIA, > >Tom Grenier > >DBA, Biztravel.com > > A larger varchar will use more memory internally and in applications. There > may be some extra overhead on the CPU during some applications. > I'm not sure about this. The way varchar is stored internally is the first byte is allocated to the size of the column and other such info., while the entire varchar structure internally cannot exceed 256 bytes. Hence the 1 + 255 implementation. To Tom's point, defining a varchar(100) vs varchar(255) won't take up any additional space IF all data is no more than 100 bytes. 7.22 onwards table alters redefining varchar columns with larger sizes are supposed to be improved and maintain contiguous byte stream, unlike previous versions when they put a pointer in the last byte to the continuation of the record elsewhere on the disk. Arun > > You could set it to a larger value then you need now and alter it later. > Many newer versions on Informix won't even rebuild your table when you > increase it. > > S.W. > wilcoxon@pioneerplanet.infi.net