FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


What MySQL Data type would you use to store a Webpage





Possum
Hi

What Data type would you recommend me to use to store all the HTML in a Web page in a MySQL fle

Thank you.
Peterssidan
I don't know what is best but you could just store the path to the HTML file to be included as VARCHAR.
If you want to store the whole page in MySQL I recommend using TEXT, or MEDIUMTEXT depending on your HTML length requirements. if you think some pages are likely to be more than 65536 bytes use MEDIUMTEXT, otherwise use TEXT.
Flakky
I think you probably need TEXT or maybe more as you can easily get to 65536 bytes. Unless you got small pages of course. Better yet find your biggest page, save it as a html document and see how big it is.

EDIT: Ok maybe a TINYTEXT is enough. I measured one of my own pages and it's far below.
Possum
I guess I will go with TEXT.

Is there an upper limit for TEXT..

What Data type can take the most text (HTML)

Thx..
Nemesis234
Possum wrote:
I guess I will go with TEXT.

Is there an upper limit for TEXT..

What Data type can take the most text (HTML)

Thx..

CHAR( ) A fixed section from 0 to 255 characters long.
VARCHAR( ) A variable section from 0 to 255 characters long.
TINYTEXT A string with a maximum length of 255 characters.
TEXT A string with a maximum length of 65535 characters.
BLOB A string with a maximum length of 65535 characters.
MEDIUMTEXT A string with a maximum length of 16777215 characters.
MEDIUMBLOB A string with a maximum length of 16777215 characters.
LONGTEXT A string with a maximum length of 4294967295 characters.
LONGBLOB A string with a maximum length of 4294967295 characters.
rickylau
According to MySQL reference manual (or as Nemesis just mentioned), TEXT column can be as large as 2^16 - 1 bytes, about 64 kilobytes. If you are looking for a larger space (complicated webpage can be as large as hundred kilobytes) you may use MEDIUMTEXT which can store 2^24 - 1 bytes (~16 megabytes). The largest text datatype is LONGTEXT, at the maximum size of 2^32 - 1 bytes (~4 gigabytes)

Additionally, BLOB types stores the text data as binary (i.e. with exactly encoding when data is inputted) while TEXT types converts text to the storage's encoding (say your database uses Unicode as encoding, each character you store into database will consume 2 or more bytes even if you are inputting 1 byte ASCII characters)
Peterssidan
You should check the MySQL reference manual for this kind of information.
http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html#id3038821

The upper limit of text is 65535 bytes. The largest text data type is LONGTEXT with an limit of 4294967295 bytes (4 GB).

I don't think the performance will change much or anything depending on type. The real difference is how many bytes each type use to store the length of the text. So if you use TEXT instead of LONGTEXT you will save 2 bytes per record, 2 bytes per page in your case.

For me it feels safer to use a smaller type because I can be sure that no record is taking up all the space even if I happen to make something wrong, like forget to put a php length check on a guestbook. Just in case.
Related topics
php image exif functions
Fortran Tutorials(77)
Help on Backing up MySQL Databases
Prefix 0 in int data type in SQL
Separating contents of MySQL row and put them in variables?
MySQL Data Not Inserting - I keep getting an error
PHP/MySQL challenge, take it if you dare
Mysql 5.0 and its limitation
whats wrong with this mysql query?
uploading and retriving images from mysql
Number or date/time field for timestamp?
Check the closest event in Calendar?
mySQL help needed, any other good database thing?
Storing MySQL connection data securely and conveniently
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.