joe92 Posted February 17, 2011 Share Posted February 17, 2011 Quite a few results coming up on google searches so thought I would ask you guys for your opinion: An email stored in the members table, I am currently using varchar(75). Is there a recommended length? And is varchar even the correct type? Quote Link to comment https://forums.phpfreaks.com/topic/227988-varchar-length-for-user-email/ Share on other sites More sharing options...
Pikachu2000 Posted February 17, 2011 Share Posted February 17, 2011 Technically, according to the RFCs, a valid email address can be up to 321 characters. Quote Link to comment https://forums.phpfreaks.com/topic/227988-varchar-length-for-user-email/#findComment-1175629 Share on other sites More sharing options...
chaseman Posted February 17, 2011 Share Posted February 17, 2011 You have to use your gut instinct and your internet savvy-ness. Of all emails you've seen how many of them were 300+ characters long? Maybe none. If you have 99% of people being fine with your 75 chars restriction, does it justify to put the setting to 300+ character for that one guy with a very long email address? I don't think so, should he use his second, or third email address (which are shorter) to sign up on your website. Why would you waste resources for that 1%. I think 80 chars is a good area, I haven't really seen too many emails longer than that, most people try to aim for something short and catchy. Quote Link to comment https://forums.phpfreaks.com/topic/227988-varchar-length-for-user-email/#findComment-1175780 Share on other sites More sharing options...
Philip Posted February 17, 2011 Share Posted February 17, 2011 I typically do 150 - 250 depending on the type of site. Quote Link to comment https://forums.phpfreaks.com/topic/227988-varchar-length-for-user-email/#findComment-1175812 Share on other sites More sharing options...
Pikachu2000 Posted February 17, 2011 Share Posted February 17, 2011 You have to use your gut instinct and your internet savvy-ness. Of all emails you've seen how many of them were 300+ characters long? Maybe none. If you have 99% of people being fine with your 75 chars restriction, does it justify to put the setting to 300+ character for that one guy with a very long email address? I don't think so, should he use his second, or third email address (which are shorter) to sign up on your website. Why would you waste resources for that 1%. I think 80 chars is a good area, I haven't really seen too many emails longer than that, most people try to aim for something short and catchy. What resources would you be wasting? Quote Link to comment https://forums.phpfreaks.com/topic/227988-varchar-length-for-user-email/#findComment-1175821 Share on other sites More sharing options...
chaseman Posted February 17, 2011 Share Posted February 17, 2011 What resources would you be wasting? I don't know, you're free to correct me if I'm wrong, you're the expert. As far as I've understood database design you should be using as much as necessary and as little as possible to create an efficient database design, it make it perform faster. Quote Link to comment https://forums.phpfreaks.com/topic/227988-varchar-length-for-user-email/#findComment-1175826 Share on other sites More sharing options...
.josh Posted February 17, 2011 Share Posted February 17, 2011 I don't know, you're free to correct me if I'm wrong, you're the expert. As far as I've understood database design you should be using as much as necessary and as little as possible to create an efficient database design, it make it perform faster. Well that's the great thing about the varchar column type. If you do like varchar(75) it will accept a string up to 75 characters long, but it will use only what the actual length of the string is. So if the email address is only 10 characters in length, there's not gonna be an extra 65 characters sitting there empty, no "whitespace buffer" to speak of (with other column types, this does happen). Anyways, it's more a matter of principle than resources. People pick and use email addresses they can remember. It is a reasonable assumption to make that a super long email address, while technically valid, probably doesn't belong to a human, but a bot. I mean TBH, I think even 75 is too much. Quote Link to comment https://forums.phpfreaks.com/topic/227988-varchar-length-for-user-email/#findComment-1175836 Share on other sites More sharing options...
chaseman Posted February 17, 2011 Share Posted February 17, 2011 Well that's the great thing about the varchar column type. If you do like varchar(75) it will accept a string up to 75 characters long, but it will use only what the actual length of the string is. So if the email address is only 10 characters in length, there's not gonna be an extra 65 characters sitting there empty, no "whitespace buffer" to speak of (with other column types, this does happen). Ohh I didn't know this was a varchar specific thing, learned something new, thanks for letting me know. Anyways, it's more a matter of principle than resources. People pick and use email addresses they can remember. It is a reasonable assumption to make that a super long email address, while technically valid, probably doesn't belong to a human, but a bot. I mean TBH, I think even 75 is too much. I definitely agree, it's a matter of principles. I don't see a reason to allow 300 characters, if somebody wants to sign up he simply should use a different email address, something more usable, just because I didn't design the website for emails that long. I purposely say "usable" because I find emails that long useless, it's easy to put a spelling mistake into such long emails, they are hard to work with. Quote Link to comment https://forums.phpfreaks.com/topic/227988-varchar-length-for-user-email/#findComment-1175838 Share on other sites More sharing options...
joe92 Posted February 19, 2011 Author Share Posted February 19, 2011 Thanks for all the replies. I have decided upon using VARCHAR(321) as I have htmlentities running through all email inputs forms, and to send an email without being a paying customer they have to enter a CAPTCHA code so bots can eff off. I see it like so. If I lose 1% of customers because of having a 'short' varchar length, and somewhere else in the site another 1% of customers dislike a function or something, and another 1% somewhere else it could add up to losing 10% of my customer base purely over such a little thing. Best to account for all things to start with, especially as it requires such little work to set a varchar length. Quote Link to comment https://forums.phpfreaks.com/topic/227988-varchar-length-for-user-email/#findComment-1176787 Share on other sites More sharing options...
Pikachu2000 Posted February 19, 2011 Share Posted February 19, 2011 What do you mean by this, "I have htmlentities running through all email inputs forms"? Quote Link to comment https://forums.phpfreaks.com/topic/227988-varchar-length-for-user-email/#findComment-1176797 Share on other sites More sharing options...
joe92 Posted February 19, 2011 Author Share Posted February 19, 2011 Sorry, misunderstanding, my mind was in a different place. This bares no relevance to why I chose the length. Quote Link to comment https://forums.phpfreaks.com/topic/227988-varchar-length-for-user-email/#findComment-1176802 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.