klepec Posted June 18, 2012 Share Posted June 18, 2012 Hi, TEXT vs VARCHAR, what do you guys think it is better to use (for longer texts like messages or news - UTF8 encoding)? Quote Link to comment https://forums.phpfreaks.com/topic/264406-text-vs-varchar/ Share on other sites More sharing options...
smoseley Posted June 19, 2012 Share Posted June 19, 2012 TEXT was designed for the purpose of storing large chunks of text. In earlier versions of MySQL (< 5.0), VARCHAR was limited to 255 characters. If backwards compatibility is important, don't use it for large text columns. Both VARCHAR and TEXT support FULLTEXT indices. So there aren't any text search benefits to either. However, VARCHAR indices (other than FULLTEXT) are a bit faster, so VARCHAR outperforms TEXT on shorter bits of text, e.g. names and tokens. Overview: - If you want backwards compatible, use TEXT - If not, use either Quote Link to comment https://forums.phpfreaks.com/topic/264406-text-vs-varchar/#findComment-1355050 Share on other sites More sharing options...
klepec Posted June 19, 2012 Author Share Posted June 19, 2012 Thanks for the information Quote Link to comment https://forums.phpfreaks.com/topic/264406-text-vs-varchar/#findComment-1355090 Share on other sites More sharing options...
smoseley Posted June 19, 2012 Share Posted June 19, 2012 Sure thing... one other tidbit. Even today, VARCHAR is limited to 64k in size. So if you are storing text that could exceed that amount, go with TEXT, which has unlimited storage. Quote Link to comment https://forums.phpfreaks.com/topic/264406-text-vs-varchar/#findComment-1355101 Share on other sites More sharing options...
fenway Posted June 30, 2012 Share Posted June 30, 2012 Also, for non-ascii, bytes <> characters. Quote Link to comment https://forums.phpfreaks.com/topic/264406-text-vs-varchar/#findComment-1358159 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.