Go to the first, previous, next, last section, table of contents.


What are the different row formats? Or when to use VARCHAR/CHAR?

MySQL dosen't have true SQL VARCHAR() types.

MySQL has instead 3 different ways to store records and uses this to emulate VARCHAR():

If one doesn't use any of the VARCHAR, BLOB or TEXT column types a fixed row size is used, otherwise a dynamic row size is used. CHAR() and VARCHAR() are treated identically from the applications point of view; Both truncates end space from the column when the column is accessed.

You can check the format used in a table with isamchk -d.

MySQL has three different table formats:

  1. Fixed length tables.
  2. Dynamic tables
  3. Compressed tables:

MySQL can support different index types, but the normal one is NISAM. This is a B-tree index and one can roughly calculate the size for the index file as: sum over all keys:

(key_length+4)*0.67

(This is for the worst case when all keys are inserted in sorted order.

String index are space compressed and if the first index part is a string it will also be prefix compressed. This will usually make the index file smaller if the columns are not filled up to 100% or if there are many duplicates.


Go to the first, previous, next, last section, table of contents.