Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

What is the storage overhead in using VARCHAR in MySQL

Answer:

MySQL allow VARCHAR to have length from a value from 0 to 65,535.

Since MySQL need to store the length of each VARCHAR field, in additional to the actual data itself, it needs 16 bits = 2 bytes for each field. But if the length of VARCHAR during table creation is less than or equal to 255, it only take 1 byte per field.

Reference: http://dev.mysql.com/doc/refman/5.1/en/char.html

  1. Optimize table in MySQL
  2. Trailing spaces of char in MySQL
  3. Changing the default storage engine in MySQL
  4. Show which storage engines are available in MySQL
  5. Repair table in MySQL

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>