Re: CHAR vs VARCHAR
Posted by:
B C
Date: August 23, 2008 09:39PM
Matthew,
The final decision is your call. Here are the pros and cons of each. The only real benefit to using CHAR is that it allows MySQL to run select statements a bit quicker since all the records are of a fixed length. I don't know how *much* quicker though. I suggest you use VARCHAR and then switch to CHAR if performance is a problem.
VARCHAR
- Trailing white space is preserved. (MySQL 5.0.3+ only.)
- Minimal storage overhead. A 17 character record takes up only 17 characters of space.
- Slower SELECTs when searching this column.
CHAR
- Trailing white space is always removed.
- Every record takes up a fixed amount of space - 19 characters in your case. Your 17 character records will waste two bytes of storage.
- Faster SELECTs when searching this column.
Source:
http://dev.mysql.com/doc/refman/5.0/en/char.html
Subject
Written By
Posted
Re: CHAR vs VARCHAR
August 23, 2008 09:39PM
September 02, 2008 07:49PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.