I will always be entering things of 20 characters into a particular column in my table.
I need this column to be unique.
Will there be any speed difference in SELECT queries if I set this column to be a varchar(255) instead of varchar(20)?
(data entered will always be 20 characters)
解决方案
if data entered will always be 20 characters than why not consider using char(20). using varchar(20) will use 20 bytes for storing character and 1 byte for storing length. so if there are 1 million records, 1 million bytes will be wasted.
as far as speed is concerned between varchar(20) and varchar(255), then I dont think it might be very hard to pick one of them, both of them will be using 21 bytes, I dont see any significant performance benefit or loss of one over other.