Re: char or varchar for small colums?
Posted in 1998
Francisco Reyes > On Fri, 16 Jan 1998 12:09:21 -0500, Art S. Kagel wrote: > >Rainer Schaub wrote: > >RULE OF THUMB: > >If you have a column that may contain a few characters in most rows but > >many more characters in other rows then use varchar to save disk space. > >For small columns and any relatively fixed size strings use char. > Thanks (Kagel and Schaub) for the feedback. > I am aware of the possible drawbacks of varchar if it needs to > expand. Most of the fields I decided to use varchar will rarely ever > change. The ones that may change more frequently I used a minimun > (after determining what is the average lenght) to minimize the need > for the column to expand beyond it's original size. > Most of the tables I will be using varchar have over 100K records so > it will help reduce space use considerable. > Is the overhead of varchar at write time or both reading and writing? > Will using minimun size help? > I have many fields which in average have half it's size in use. Will > it help to set the minimun to this average? I am asking this mostly > for records which may change somewhat frequently. For records which > will rarely ever change I am considering setting no minimun. There is no appreciable overhead to varchar fields either inserting or fetching if the row is not moved. There is some small front end overhead in fetching a varchar field into a fixed length character host variable (type char or string) needed to expand the field with spaces. This is minor and where it is a concern host type varchar can be used. Art S. Kagel