Why do so many developers set varchar to 254 and not 255 when creating MySQL tables?
Proof that this happens: mysql varchar 254
Your Google query gave you the hints already. One of the first hits is this:
https://www.vbulletin.com/forum/project.php?issueid=32655
It basically says, that FULLTEXT
indexes on VARCHAR(255)
require twice the space of a VARCHAR(254)
FULLTEXT index. And some more other bloat on top of that.
I think this is far more important than saving one byte in the data table.
varchar fields require n+1 bytes for fields less than or equal to 255 and required n+2 bytes for fields > 255
http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html
It should be set to 255, I'm assuming developers think they will save an extra byte from 254, but 255 is the standard
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