View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 07:52 AM
Peter H. Coffin
 
Posts: n/a
Default Re: Constant char length is a good practice?

On 30 Jun 2006 09:07:29 -0700, howachen@gmail.com wrote:
> Hi,
>
> People said that using constant char length is a good practice as the
> speed of accessing of a row is faster.
>
> However, as the size of the table might get bigger and bigger, is this
> really a good trade off?


I don't know about mysql specifically, but it's far less important than
it used to be -- varchar speed's pretty good these days. Additionally,
most engines in general don't ever shrink the varchar spaces of a
particular record, short of reorganizing a table (if supported), or
reimporting it. So, while a char table may grow quickly with inserts
(gotta hold all that unused space), a varchar table ends up growing some
even with just updates and tends (over time) to approach the size of the
char table anyway.

So, I guess I wouldn't really worry about using char instead of varchar
unless I had a small table, with well-chosen column specifications (not
much wild variation in the widths of data in the char columns), where
all the records were expected to change rapidly.

--
Cunningham's Second Law:
It's always more complex than you expect, even when you take
Cunningham's Second Law into account.
Reply With Quote