Jump to content

[SOLVED] MySQL Memory Usage on Text data types


theinfamousmielie

Recommended Posts

Hey all,

 

I'm trying to find out which is the most memory efficent (and therefore server-friendly) datatype to use for a text field that could have between 1 and several million characters. It's for content storage on a content-management system, so the majority of information would probably be less than 65535 characters (page titles, headings, etc) but i still need to be able to store large amounts of data if need be.

 

Currently using 'MEDIUMTEXT'. ;D total overkill for now ... but i'm trying to futureproof and cover all bases.

 

Any ideas?

Link to comment
Share on other sites

Hi Fenway,

 

Aaah okay. Well you learn something (simple) every day! hehehe.

 

Unfortunately, while the majority of data going into that field will be well under 65k characters, there will be a need to store more information occasionally, perhaps a very long html page, or large XML document. Is the benefit gained so great that i should essentially say 'tough luck' to content larger than 65k characters? or should i stick with MEDIUMTEXT ?

 

Link to comment
Share on other sites

Just remember that even though VARCHAR is better than TEXT, any temporary table operation (e.g. filesort from grouping/ordering, subqueries) will silent convert VARCHAR to CHAR, so it will take up the maximum amount of bytes!  So use the "full length" with caution

Link to comment
Share on other sites

Won't be any of those :)

 

Essentially, it's for a content management / templating type system.

 

The main table, which contains the layout and other information (the Content) table has reference to a layout file and menu items and where it sits in the site tree etc etc. The table that holds the VARCHAR/TEXT field in question is almost like an interlinking table so as such we're referencing it by an ID 99% of the time. So this table has three columns. ContentID (which references it to a particular 'page'), FieldVariable (which contains the variable used in the template which will be searched for and replaced with the actual data) and FieldData ... which is the field in question.

 

My replacement query will be something like "SELECT FieldData FROM _ContentData WHERE ContentID = 1 AND FieldVariable = '##REPLACEME##' " - which should be quick and clean, regardless of data type.

 

Having said that, this may not be the most efficient way of doing it ... it's still very much in prototype. But does it make sense, and with that in mind, does the memory thing even matter? (the only time the FieldData column is referenced is in a FullText search if needed)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.