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.
If it can only be 20, why would you want to specify 255? If it is always 20, even char(20) would be better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With