List:General Discussion« Previous MessageNext Message »
From:Paul Schmidt Date:August 22 2000 1:22pm
Subject:Re: CHAR vs VARCHAR
View as plain text  
I have been following the CHAR vs VARCHAR war for a few days now, and find
the whole thing kind of funny, but worth comment.

-----Original Message-----
From: Kris Dahl <krislists@stripped>
To: jan.dvorak@stripped <jan.dvorak@stripped>
Cc: mysql@stripped <mysql@stripped>
Date: Monday, August 21, 2000 6:52 PM
Subject: Re: CHAR vs VARCHAR


>
>> CHARs can be faster than VARCHARs if the following conditions are met:
>> 1. You didn't do OPTIMIZE TABLE often enough;
>> 2. The table can fit in the O/S buffer cache anyway.
>> If the table (plus a substantial part of its index)
>> doesn't fit in the core, disk speed becomes the hurdle
>> and then, it's pretty much obvious that the less data you have
>> to pass through the core, the sooner a query is finished.
>
>I have found that even immediately after a optimize, on smaller tables at
>least (I think I tested it on a 30k row table) converting from
VARCHAR->CHAR
>was still significantly faster.  Your millage will obviously vary depending
>on the application.


If you *really* need the speed advantage of using CHAR or the space
advantage of the VARCHAR then the server wasn't sized properly in the first
place.  Fields should be defined as to what they will contain, a field of
fixed size values, like Licence plate numbers, should be defined as a CHAR;
a field of variable length values, like names, should be defined as VARCHAR.
This assists with self documenting the tables, so that the DBA can look at
the definition, and get an idea of what is going on.  The same idea goes for
the Enum, if an enumerated field is the best bet, then use it.

You never know what the future will bring, new database technologies, may
eliminate the advantage, your carefully mangled database has, or you may get
a $50,000 budget for a new server, so it doesn't matter anymore.

Paul

Thread
CHAR vs VARCHARClaude Cormier21 Aug
  • Re: CHAR vs VARCHARRob McMillin21 Aug
  • Re: CHAR vs VARCHARClaude Cormier21 Aug
    • RE: CHAR vs VARCHARSander Pilon21 Aug
  • Re: CHAR vs VARCHARKris Dahl21 Aug
    • Re: CHAR vs VARCHARJan Dvorak21 Aug
      • Re: CHAR vs VARCHARKris Dahl22 Aug
  • Re: CHAR vs VARCHAREd Wang21 Aug
Re: CHAR vs VARCHARKris Dahl21 Aug
  • RE: CHAR vs VARCHARChristopher Thompson21 Aug
    • RE: CHAR vs VARCHARDana Powers21 Aug
    • Re: CHAR vs VARCHARSteve Ruby21 Aug
  • Fastest way to select setsChristopher Thompson21 Aug
    • Re: Fastest way to select setsSteve Ruby22 Aug
    • Re: Fastest way to select setsTonu Samuel22 Aug
      • Re: Fastest way to select setsTino Hendricks28 Aug
        • Re: Fastest way to select setsTonu Samuel2 Sep
Re: CHAR vs VARCHARPaul Schmidt22 Aug