Jump to content

Simple Question About MySQL Text Field Types


webref.eu

Recommended Posts

With just that description I'd probably do a VARCHAR(1000). VARCHARs are stored inline in the table, like the other normal types like INT and CHAR, so they're pretty fast. You should be extra wary of SELECT *s as you could be pulling this text data and then not using it, which is wasted time and bandwidth.

 

MySQL has size limits on rows, though. 8KB I think. If you needed anything close to that, or had more than one large VARCHAR column, then you may have to switch to TEXT. TEXT (and BLOB) are stored outside the table, which means they're a little slower but obviously you can store much more. VARCHARs may be stored outside too if you ask for a large enough size.

 

Here's a question: is the 1000 arbitrary? Think you might expand it at some point? Does this field represent a free-form input from the user? Are you making sure to enforce a 1000 character limit? Depending on your answers, TEXT may be more appropriate in terms of data modelling, even if it means a bit (a bit) less performance.

Edited by requinix
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.