Re: Mysql/php database performance question
| From: | Marek Kilimajer | Date: | Fri, 10 Jan 2003 16:45:09 +0000 |
| Subject: | Re: Mysql/php database performance question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-131141@lists.php.net to get a copy of this message | ||
Sure, just tried it (32-bit platform, might be >7 for 64-bits).
I have a feeling it is somewhere in the manual.
Matt Schroebel wrote:
-----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 questionchar of greater size than 3 is converted to varchar anywaysAre 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