MySQL Question

Don Erickson derick at zeni.net
Mon Jun 6 14:02:04 CDT 2005


On Mon, 6 Jun 2005, Josh Charles wrote:

> I've been trying to figure this out, but have been coming up blank.
> For some reason, I can't figure out the right google term to use, and
> the MySQL books I have don't really address this.
>
> I'm working with a website that will have many, many pieces of text I
> need to store in the database.  Most of these texts will be less than
> 10,000 Characters, while a few will could be as great as 100,000
> characters or more.  I won't be able to know ahead of time.

My understanding is that TEXT type fields don't allocate anything unless
they need the space to store actual data, essentially like VARCHAR.  So,
TEXT, LONGTEXT, MEDIUMTEXT, etc. differ only in their maximum data size,
and the actual mysql table would be essentially the same size unless these
maximum sizes were exceeded in a field and thus truncated.

So, if I understand your question correctly, if you want to store all
possible honker articles, you can use LONGTEXT and this will only add a
few extra bits to each data field.

Okay, here's mysql's table of capacity:

TINYTEXT:   2^8
TEXT:	    2^16
MEDIUMTEXT: 2^24
LONGTEXT:   2^32

So, I guess you'd need MEDIUMTEXT to store articles of up to 16,777,216
characters, and there'd be no bloat.

LONGTEXT could go to 4,294,967,296 characters, and still no bloat.

I belive that TEXT field suppport is fairly new in mysql, or at least I
haven't known about it for very long.


Regards,

-Don


More information about the Kclug mailing list