how long of an email address to accept?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

how long of an email address to accept?

Post by daedalus__ »

hey how long of an email address will you generally accept into a database?

the longest an email address can be is what 300 some odd characters? if you have tens of thousands of users that could translate into a lot of space, couldn't it?

thoughts?

im trying to decide somewhere between 32 and 64 characters. i mean, if you are using one longer than 32 characters you could very easily be an e-douche. but then you may just have a very long name. i don't want to support the full 64/255 or whatever it is. stop using your abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com email.

from what ive been reading about 32 characters a little over should cover most people.
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

Re: how long of an email address to accept?

Post by aravona »

Most people tend to use shorter personal email addresses eg. example@example,com

Work emails addresses can be really long (mine is 40 characters start to finish) so I think 45 should cover most addresses
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Re: how long of an email address to accept?

Post by Jenk »

Why not just accept any address that is valid, regardless of length and worry about diskspace if and when it becomes an issue?

There's an RFC822 validation class posted in the snippets/critique section (you'll need to search)
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: how long of an email address to accept?

Post by onion2k »

I use varchar(250) to store them.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: how long of an email address to accept?

Post by josh »

User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Re: how long of an email address to accept?

Post by Bill H »

if you have tens of thousands of users that could translate into a lot of space, couldn't it?
MySQL, and I assume other db's, only use the amount of space required by the actual data for strings, regardless of the space you define as allowed. A VARCHAR(250), for instance, containing the text "foobash" would only use up 8 bytes, seven for the text and one byte to indicate the length of the string. So when you define the length in the column definition, you are not saying how many bytes will be used by the database, only the maximum number that can be used.

Anything longer that VARCHAR(255) in MySQL is automatically converted to type TEXT, where length is essentially no longer an issue.

So, while a very few might have 300-odd character email address, the vast majority will have much shorter ones, and it doesn't matter how many characters you allocate for those shorter ones, they won't use any extra space.
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: how long of an email address to accept?

Post by daedalus__ »

yeah i remembered that after i posted this. char is fixed width varchar isnt. and i read that if you do not use variable width columns in a row then you can gain a small performance increase
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Re: how long of an email address to accept?

Post by Jenk »

This highly smells of premature optimisation.
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Re: how long of an email address to accept?

Post by Bill H »

i read that if you do not use variable width columns in a row then you can gain a small performance increase
I'm not sure how much it would improve or what the real gain would be in a practical sense. And if the table has any variable column in it then all CHAR columns longer than three characters are "silently" changed to VARCHAR columns by MySQL, so it is an "all or nothing" situation.
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: how long of an email address to accept?

Post by daedalus__ »

User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: how long of an email address to accept?

Post by Darhazer »

Yeah, it is important to note, that fixed width have advantages if you use MyISAM and not InnoDB. And this is a storage-engine dependent optimization. Anyway, disk space is cheap, and it's much better to waste disk space then to disappoint your customers by not accepting their e-mail address. A friend of mine have an e-mail at abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com

So, please accept such long e-mail address, or you will loose him as a user ;)
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: how long of an email address to accept?

Post by daedalus__ »

yeah i was looking at that the other day. id impose a limit just to keep someone from using an e-mail address like that. haha. it's e-douchy.
Post Reply