MySQL Forums
Forum List  »  General

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

Options: ReplyQuote


Subject
Written By
Posted
August 18, 2008 12:49PM
Re: CHAR vs VARCHAR
B C
August 23, 2008 09:39PM
August 27, 2008 11:35PM
August 28, 2008 07:52AM
B C
August 28, 2008 06:38PM
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.