Re: Char vs. Varchar
Posted in 1994
ar@mai.de (Achim Reiners) writes: >Hello Informixers! >I don't know if the discussion about the usage of varchar vs. char fields >took already place here in this group. So my question: >In our application which is in production since april, I defined >a lot of columns as char(60). Now I see with the production data that >the average length of this data is only 6-10 characters. >To save space I am now thinking to change them to varchar(60). >On some of these columns we have Indexes to speed up queries. >My question: >Are accesses through indexes on varchar columns slower than on char >columns? Personnal experience says yes. I avoid making any indexed column a VARCHAR unless I know the index will be infrequently used. >A general question: When is it recommended to use varchar instead of char? >Is there a magic number of (average string length) / (max string length) ? My instinct is to use VARCHAR when the length is 25+ characters, it will often be shorter than that, and not an indexed column. >Is there any good reason still to use char except when I know that all >records have the same length with this field? VARCHARS have some anomolies is displaying and printing that also at times prevent me from using them. There are ways around all that I've run into, but they do increase the Kludge factor of the code by a percentage point. Also, if there is any chance of the database being used with Standard Engine instead of OnLine, I might avoid VARCHARs because they are not a feature of SE. ============================================================ Dennis J. Pimple Informix Software Inc Senior Consultant Denver Colorado USA dennisp@informix.com Voice:303-850-0210 Fax:303-779-4025