I'm trying to generate a little more performance from a particular table full of hundreds of thousands of rows. There are a few VARCHAR fields that I'm converting to CHAR.

I'm aware that I won't get the speed benefit of switching to fixed length CHAR fields if any variable length rows exist in my table. However, when I search for a list of all fixed length–or variable length–field types for MySQL, I come up short. My table contains a few DECIMAL and DATETIME fields. I'm somewhat sure the latter is fixed, but the former? Not sure.

Does anyone have a definitive list?


See from the official MySQL documentation: section Data Type Storage Requirements has it all.

  • Great. VARCHAR, VARBINARY, and the BLOB and TEXT types are variable-length types. I'm assuming that's it? If so, excellent. – Stephen Nov 8 '10 at 16:09
  • Yep, those are all variable types. – Janne Pikkarainen Nov 8 '10 at 16:31
  • Not to beat a dead horse, but: "those are all variable types" or "those are all of the variable types" ? I want to make sure I'm not missing any. ;) – Stephen Nov 8 '10 at 17:15
  • @Stephen: Those are all of the variable types that I know of. But be warned: if you truly want to be sure you don't miss anything, then you'll also need to learn about how different MySQL storage engines (MyISAM, InnoDB ...) handle these things. – Janne Pikkarainen Nov 8 '10 at 17:18

The length of a CHAR column is fixed to the length that you declare when you create the table. The length can be any value from 0 to 255

Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 65,535

I always thought it was better to use VARCHAR.. as the variable length is better than the static CHAR

  • Right, VARCHAR is nice. But if all of your columns are fixed length, MySQL can burn through your queries faster. – Stephen Nov 8 '10 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.