Most of the other answers here focus on the fact that VARCHAR is stored in a variable length, so it stores the number of bytes of the string that you enter in the given string, and not the maximum field length.
But during queries, there are some circumstances where MySQL converts VARCHAR to CHAR - and therefore, the size increases to the maximum length. This happens, for example, when MySQL creates a temporary table during JOIN or ORDER BY or GROUP BY operations.
Itβs difficult to talk about all the cases when this will be done, because it depends on how the optimizer processes the query, it depends on the different table structure and indexes that you define, it depends on the type of query, and it even depends on the version of MySQL. as the optimizer is improved with each version.
The short answer is yes, there may be a difference if you use VARCHAR (255) or VARCHAR (30). Therefore, determine the maximum column length according to what you need, and not the βlongβ length, such as 255, for tradition.
Bill karwin
source share