I'm struggling to find enough documentation to help me answer my own question.
The common story seems to be that it doesn't make a difference to actual database size when you use a much higher value for n
than will ever be used.
As an extreme example: VARCHAR(5000) but only storing on average a small number of characters such as 4 characters.
That seems to be correct from a few tests I've run.
I've heard people saying that MySQL will take the higher value into account when managing pages meaning a potential for less records per page and that this can affect performance when running queries.
I can't see anything in the documentation to suggest this is actually the case so really looking for some clarity from a more experienced DBA.
So thanks in advance for any help. Please let me know if my question needs to be clearer. My question is, does using a higher value for varchar(n) than will be stored affect the number of records which can be stored per page even if you store less than n?
I'm pretty new to this so if possible I'd also really appreciate a steer on how I can determine how many records are included in pages and then run some benchmarks.
CHAR(5000)
if your query needs to store such column in a temp table - the table gets big fast and then spills to disk (transforming to temporary MyISAM) which can make your query slower.ROW_FORMAT
?