View Single Post

   
  #4 (permalink)  
Old 02-28-2008, 07:53 AM
howachen@gmail.com
 
Posts: n/a
Default Re: Constant char length is a good practice?


Bill Karwin 寫道:

> howachen@gmail.com wrote:
> > People said that using constant char length is a good practice as the
> > speed of accessing of a row is faster.

>
> Here's the page that describes the advantages of using fixed-length CHAR
> columns over dynamic-length VARCHAR columns.
>
> http://dev.mysql.com/doc/refman/5.0/...ic-format.html
>
> This applies only to MyISAM tables. Note also that _all_ the columns in
> a table must be fixed-length datatypes, or else you don't get the
> advantage. That is, if the table contains at least one VARCHAR, BLOB,
> or TEXT column, then that whole table is stored as a dynamic table.
>
> That doc page does say that fixed-length rows have some performance
> advantage, but it doesn't quantify it. So it could be a trivial advantage.
>
> I usually use the datatype that most fits the application, then worry
> about optimizations if I determine that it's causing a bottleneck.
> Other improvements like indexes and caches are almost always more
> important than the performance difference between CHAR and VARCHAR.
>
> Regards,
> Bill K.


thanks.

Reply With Quote