List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:March 26 2002 4:07pm
Subject:RE: Enforcing Column Types
View as plain text  
At 16:55 +0100 3/26/02, Roger Baklund wrote:
>* Paul DuBois
>>  At 15:23 +0100 3/26/02, Tino Didriksen wrote:
>>  >Question about the CHAR to VARCHAR conversion of:
>>  >http://www.mysql.com/doc/S/i/Silent_column_changes.html
>>  >
>>  >Now, I can see the logic in changing most CHAR to VARCHAR if
>>  they are long
>>  >and variable sized.
>>  >I have a column that is VARCHAR(32). I use it to store MD5 hash
>>  values. MD5
>>  >hashes are always 32 byte.
>>  >In other words, that's 1 byte wasted because it's VARCHAR.
>>  >
>>  >With 2500 entries and more on the way, that's at least 2500 byte wasted.
>>  >
>>  >Is there no way to enforce a column type around the silent changes?
>>
>>  No.  It makes no sense to do so.
>
>well... even if 2500 bytes is insignificant, I think his question makes
>sense...
>
>The only way I know to enforce CHAR is to make sure all other columns in the
>table are of fixed size types... ie not *TEXT, *BLOB or VARCHAR.

That's why it doesn't make sense to have just a single column be CHAR.
As soon as a table has even one other variable-length column, the entire
table becomes a variable-length-row table and any advantages of having
fixed-length rows are lost.  Even in the case that a column might always
have 32 bytes, the single-byte advantage that you might get from using a
CHAR are presumably offset by savings in the other variable-length columns.
If the latter is not true, then those columns should be changed to fix-length
types anyway.



>
>--
>Roger
>query

Thread
Enforcing Column TypesTino Didriksen26 Mar
  • Re: Enforcing Column TypesKeith C. Ivey26 Mar
  • Re: Enforcing Column TypesPaul DuBois26 Mar
    • RE: Enforcing Column TypesRoger Baklund26 Mar
      • RE: Enforcing Column TypesPaul DuBois26 Mar
Re: Enforcing Column TypesJoel Rees27 Mar
RE: Enforcing Column TypesRick Emery27 Mar