RE: [PHP] Mysql/php database performance question
| From: | Matt Schroebel | Date: | Fri, 10 Jan 2003 16:27:07 +0000 |
| Subject: | RE: [PHP] Mysql/php database performance question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-131137@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Marek Kilimajer [mailto:kilimajer@webglobe.sk]
> Sent: Friday, January 10, 2003 11:04 AM
> To: Matt Schroebel
> Cc: Simon Dedeyne; php-general@lists.php.net
> Subject: Re: [PHP] Mysql/php database performance question
>
>
> char of greater size than 3 is converted to varchar anyways
Are you sure? I've been reading up on this stuff over the last few
days, and my understanding is that char is stored fixed width with
trailing spaces padding the string to the length specified in the
schema, whereas varchar is stored is strlen(rtrim(column))+1. So a
column char(45) will always take 45 bytes of space, while varchar(45)
will vary from 1 to 46 bytes of space.
The first way makes locating a row in the db fast (as long as all
columns are fixed width [No blob, text, or varchar columns]) since it's
simple math, whereas the latter way saves space but makes MYSQLs finding
a row a little harder (since the offset varies) and thus a bit slower.
I have always been using varchar and have been considering changing to
char.
http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html
#CHAR