If I know a value being stored in MySQL is always going to be exactly 32 characters, is it better performance to make the column type CHAR instead of VARCHAR? What exactly is the performance difference between using VARCHAR and CHAR?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would use
CHAR.If you are likely to search on the column,
CHARpresents a small performance upgrade overVARCHAR.Since your data size is going to be fixed, there is no downside to using
CHAR, as anVARCHARequivalent will store anywhere from one to two bytes as a prefix.Reference: MySQL CHAR vs VARCHAR