Hi Guys
Many thanks for the feedback.
I know this is a little off topic, but I use decimal types for my price
figures is there any problem in expanding these to say (13,6) when they are
currently (10,3).
Problems in that I am talking file size, query performance, etc.
Thanks
"Good Man" <heyho@letsgo.com> wrote in message
news:Xns9704A607FFCB8sonicyouth@216.196.97.131...
"Laphan" <info@SpamMeNot.co.uk> wrote in
news:11ml7ctkk8g3399@corp.supernews.com:
> Hi Gordon
>
> Many thanks for the feedback.
>
> The DB is purely used as the store for an ASP driven web site so apart
> from the HTML input field everything is rosy in this respect.
>
> I do try and keep my field sizes tight rather than every varchar being
> 255 chars long, but I didn't know if 100 chars slows a query down or
> is bigger in size DB wise than 70 chars. Although 70 would cover it
> 100 would definitely do it, but if it means any kind of degradation
> then I'll plumb for 70.
note that specifying the varchar length should refer to the maximum
amount of characters that will be stored in the column.
varchar is unique in that if you specify it be 255 characters long, and
only insert a value that is 8 characters long, it only records the 8
characters. This is in contrast to say "char", which will pad the
remaining 247 characters with spaces.
in other words, VARCHAR(255) will record 8 bytes of data for your 8
characters; CHAR(255) will record 255 bytes, regardless of the amount of
data in the column - 8 characters, 1 character, or 200 characters.
so, the answer to your question is that defining a varchar column with
255 characters will not make the table larger than a varchar column
defined as 15 characters - only the actual amount of data in the column
increases the size of the table/database. You have nothing to lose by
specifying your field to be 100 characters.
*****
http://dev.mysql.com/doc/refman/4.1/en/char.html
In contrast to CHAR, VARCHAR values are stored using only as many
characters as are needed, plus one byte to record the length (two bytes
for columns that are declared with a length longer than 255).
VARCHAR values are not padded when they are stored. Trailing spaces in
MySQL version up to and including 4.1 are removed from values when stored
in a VARCHAR column; this also means that the spaces are absent from
retrieved values.