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.
CHAR
.If you are likely to search on the column, CHAR
presents a small performance upgrade over VARCHAR
.
Since your data size is going to be fixed, there is no downside to using CHAR
, as an VARCHAR
equivalent will store anywhere from one to two bytes as a prefix.
Reference: MySQL CHAR vs VARCHAR