Page 1 of 1

how long of an email address to accept?

Posted: Wed Dec 16, 2009 4:26 am
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.

Re: how long of an email address to accept?

Posted: Wed Dec 16, 2009 4:38 am
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

Re: how long of an email address to accept?

Posted: Thu Dec 17, 2009 3:15 am
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)

Re: how long of an email address to accept?

Posted: Thu Dec 17, 2009 8:08 am
by onion2k
I use varchar(250) to store them.

Re: how long of an email address to accept?

Posted: Tue Dec 22, 2009 1:44 am
by josh

Re: how long of an email address to accept?

Posted: Tue Dec 22, 2009 9:45 am
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.

Re: how long of an email address to accept?

Posted: Tue Dec 22, 2009 5:58 pm
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

Re: how long of an email address to accept?

Posted: Wed Dec 23, 2009 5:31 am
by Jenk
This highly smells of premature optimisation.

Re: how long of an email address to accept?

Posted: Wed Dec 23, 2009 12:09 pm
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.

Re: how long of an email address to accept?

Posted: Wed Dec 23, 2009 1:52 pm
by daedalus__

Re: how long of an email address to accept?

Posted: Thu Dec 24, 2009 6:02 am
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 ;)

Re: how long of an email address to accept?

Posted: Thu Dec 24, 2009 9:11 am
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.