Re: MySQL Optimization Assistance


Subject: Re: MySQL Optimization Assistance
From: Joshua Kugler (jk@as.uaf.edu)
Date: Mon Nov 10 2003 - 15:47:11 AKST


Yes. VARCHAR is a variable-width field, thus it must store the actual field
length for that record at the beginning of the field. CHAR is a fixed-width
field, so when that field is encountered, a simple seek(field_width) can be
done to skip over it.

Think of a human analogy: have you ever tried to decipher a CSV export from a
spread sheet versus an export with fixed-width fields? Fixed width fields
are much faster to read (for computers AND humans).

On small tables (maybe even up into the 10's of thousands of rows) you may not
notice the difference, especially with good indexes. But when you have
hundreds of thousands of rows, I suspect you would get quite a performance
hit. Although, if you have REALLY good indexes, you'd never need to do
linear searches, which is where you'd get your performance hit.

Also, if you are doing a lot of data processing, reading a VARCHAR field will
take a little bit long because you have to read the field length, then the
field. You can't just grab the next X characters based on the table
definition of that field's width (speaking from a database software point of
view).

j----- k-----

On Monday 10 November 2003 03:32 pm, neil@neilmoomey.com wrote:
> Do you think VarChar 255 is slower than Char 255?=A0 I always use VarChar
> and= it seems fast enough.=A0 PhpMyAdmin uses VarChar by default but I've
> never u= nderstood why.
>
> Neil
>
> ---------
> To unsubscribe, send email to <aklug-request@aklug.org>
> with 'unsubscribe' in the message body.

-- 
Joshua Kugler
Assistant Systems Administrator
UAF Department of Mathematical Sciences
UAF LUG President
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.



This archive was generated by hypermail 2a23 : Mon Nov 10 2003 - 15:47:11 AKST