[development] varchar(255)

Dave Cohen drupal at dave-cohen.com
Thu Apr 23 20:09:05 UTC 2009

In another recent thread (about watchdog), Frédéric suggested increasing the size of the watchdog.referer column.  And he's right to suggest it because strings that are too long are not written to the database.

This brings to 3 the number of columns I increase to varchar(255) on my Drupal sites.  The three are watchdog.referer, users.mail, and sessions.sid.

If my understanding of mysql is correct, there is no difference between a varchar(128) column filled with 128-byte strings and a varchar(255) column filled with 128-byte strings.  However, there is a huge difference between a varchar(128) column filled with 129-byte strings and a varchar(255) filled with 129-byte strings.  (The latter will work).

So please, when developing for Drupal and wondering what size to make that varchar... stop wondering and use varchar(255).  

Or if you need it even longer varchar(65535).  Note that lengths up to 255 can be represented in one byte, and 65535 in two bytes.

Oh and please do correct me if I'm wrong about any of this,


More information about the development mailing list