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?
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.
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