2 messages in com.mysql.lists.clusterRe: TEXT vs VARCHAR(255)
FromSent OnAttachments
Simon Garner26 Jun 2005 22:40 
Mikael Ronström27 Jun 2005 00:58 
Subject:Re: TEXT vs VARCHAR(255)
From:Mikael Ronström (mik@mysql.com)
Date:06/27/2005 12:58:03 AM
List:com.mysql.lists.cluster

Hi,

2005-06-27 kl. 07.40 skrev Simon Garner:

In MySQL Cluster, what are the performance and storage pros and cons of using a TEXT vs. using a large VARCHAR?

I understand that TEXT columns are stored as separate rows in NDB. I also understand that VARCHARs are stored as fixed length. What I'm not sure of is what happens with an empty TEXT field.

If I have a column in a table which needs to contain a string and in 99% of rows the column will be NULL, is it better to make it a TEXT or a VARCHAR? I am not too worried about the maximum length - 255 would be enough (but I couldn't make it smaller than that).

If I make it a VARCHAR then every row will take 255 bytes extra, correct? Even though 99% of that will be wasted. Would making it a TEXT be worse, or better?

My memory is a bit unsafe but I seem to remember that the fixed storage for a TEXT is 256 bytes so NULL fields for TEXT and VARCHAR(255) are equal in fixed storage on the main record, the TEXT fields then grow by adding extra records 2k at a time.

Rgrds Mikael

-Simon

Mikael Ronstrom, Senior Software Architect MySQL AB, www.mysql.com

Jumpstart your cluster: http://www.mysql.com/consulting/packaged/cluster.html