Alex Rivera | Logout

Does VARCHAR size limit matter?

Asked 2010-12-01T13:35:53.170
33

Possible Duplicate:
Importance of varchar length in MySQL table

When using VARCHAR (assuming this is the correct data type for a short string) does the size matter? If I set it to 20 characters, will that take up less space or be faster than 255 characters?

Edit
Report

1 Answer

17

In general, for a VARCHAR field, the amount of data stored in each field determines its footprint on the disk rather than the maximum size (unlike a CHAR field which always has the same footprint).

There is an upper limit on the total data stored within all fields of an index of 900 bytes (900 byte index size limit in character length).

The larger you make the field, the more likely people will try to use for purposes other than what you intended - and the greater the screen real-estate required to show the value - so its good practice to try to pick the right size, rather than assuming that if you make it as large as possible it will save you having to revisit the design.

answered 2010-12-01T13:44:29.273

Your Answer