Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bigger than a char but smaller than a blob

Tags:

database

mysql

Char's are great because they are fixed size and thus make for a faster table. They are however limited to 255 characters. I want to hold 500 characters but a blob is variable length and that's not what I want.

Is there some way to have a fixed length field of 500 characters in MySQL or am I going to have to use 2 char fields?

like image 237
Teifion Avatar asked Aug 07 '08 18:08

Teifion


1 Answers

I would suggest using a varchar(500). Even though varchar isn't a fixed length, the database should reserve the correct amount of space. You shouldn't notice any performance difference using varchar(500) over 2xchar(255).

You're also probably going to cause extra overhead by joining two char fields together.

like image 59
GateKiller Avatar answered Nov 11 '22 04:11

GateKiller