Reputation: 61
If a column defined with varchar(20000)
and size of the actual data stored is around 4k-5k, Does it make any difference to MYSQL? As I read from MYSQL documentation, there is no difference in disk usage when actual data is less than declared size.
My question is, Will there be any impact in a SELECT query on this column? Could I make my queries faster by declaring the varchar
closer to the actual size I will store in it?
Upvotes: 5
Views: 222
Reputation: 17010
No. VARCHAR
strings are stored this way: some bytes are used to store the effective lenght of the string (in your case 2 bytes I think), and then N bytes are used to store the string where N is equal to the lenght of your string.
So, for example, if you store 'example'
, only 9 bytes are used.
There are no impact in SELECT
query, both for speed and memory usage.
Upvotes: 7