Kenedy
Kenedy

Reputation: 229

VARCHAR(1500) VS TEXT | Utf-8 encoding

I want to store phrases in different languages (utf-8 encoding) in a MySql innoDB table. The average data length is allways less than 100 words, so this is going to be my max limit (14 chars + blanspace), which makes each phrase have a MAX length of 1500 chars.

Assuming that MySql allows over 65000 bytes, and that each utf-8 char will need around 3 or 4 bytes, a VARCHAR(1500) is possible. [1500 chars * 4 bytes/char = 60000 bytes]

My question is, what is the difference between this and using TEXT values?. I know VARCHAR accepts Default values (different from NULL) but I need more differences... what is better (more effective in sorting and more eficient in storing - and viceversa)?

Upvotes: 1

Views: 1695

Answers (1)

Simon Germain
Simon Germain

Reputation: 6844

I believe the major difference between VARCHAR and TEXT is that VARCHAR is a fixed size. That would make any operation on the fields more efficient than dealing with any type of dynamically-sized data.

Besides that, not sure there's much difference. Feel free to chip in! :)

Upvotes: 1

Related Questions