Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Table with TEXT column

I've been working on a database and I have to deal with a TEXT field.

Now, I believe I've seen some place mentioning it would be best to isolate the TEXT column from the rest of the table(putting it in a table of its own).

However, now I can't find this reference anywhere and since it was quite a while ago, I'm starting to think that maybe I misinterpreted this information.

Some research revealed this, suggesting that

Separate text/blobs from metadata, don't put text/blobs in results if you don't need them.

However, I am not familiar with the definition of "metadata" being used here.

So I wonder if there are any relevant advantages in putting a TEXT column in a table of its own. What are the potential problems of having it with the rest of the fields? And potential problems of keeping it in a separated table?

This table(without the TEXT field) is supposed to be searched(SELECTed) rather frequently. Is "premature optimization considered evil" important here? (If there really is a penalty in TEXT columns, how relevant is it, considering it is fairly easy to change this later if needed).

Besides, are there any good links on this topic? (Perhaps stackoverflow questions&answers? I've tried to search this topic but I only found TEXT vs VARCHAR discussions)

like image 990
luiscubal Avatar asked Dec 04 '09 19:12

luiscubal


1 Answers

Yep, it seems you've misinterpreted the meaning of the sentence. What it says is that you should only do a SELECT including a TEXT field if you really need the contents of that field. This is because TEXT/BLOB columns can contain huge amounts of data which would need to be delivered to your application - this takes time and of course resources.

Best wishes, Fabian

like image 144
halfdan Avatar answered Sep 19 '22 05:09

halfdan