Ask HN: What length do you choose for email fields?
I know that the maximum length of email addresses can be 256 characters (http://en.wikipedia.org/wiki/Email_address) however, I always feel dirty about defining varchars with such large bounds and reserving such a large index size for email addresses.
Whilst obviously not in spec, I often set my email fields to 100 characters as I think that even an email address of that size is impracticable for day-to-day usage and should cover off 99.999% of address cases.
So I ask you, how big do you usually make your email address fields?
14 comments
[ 12.1 ms ] story [ 1055 ms ] threadhttp://docs.djangoproject.com/en/1.2/ref/models/fields/#emai...
My rationale is this: what percent of the DB will the extra 156 characters take? If I have 1K or less users, an extra 150KB of storage is negligible. If I have 1M users, 150MB is also silly.
But really, it should follow the RFC and use 320.
http://askville.amazon.com/maximum-length-allowed-email-addr...
From http://www.dominicsayers.com/isemail/:
"Myth: The maximum length of an email address is 320 characters
This arises from the simple arithmetic of maximum length of a domain (255 characters) + maximum length of a mailbox (64 characters) + the @ symbol = 320 characters. Wrong.
This canard is actually documented in the original version of RFC3696. It was corrected in the errata, but nobody reads the errata (except me it would appear).
There's actually a restriction from RFC 5321 on the path element of an SMTP transaction of 256 characters. But this includes angled brackets around the email address, so the maximum length of an email address is 254 characters. You read it here first.
This is not a new restriction - it goes right the way back to RFC 821 and was also in RFC 2821."
<5: 1056713 (none or fake)
5-9: 6052
10-19: 226676
20-29: 274956
30-39: 8912
40-49: 196 (from here on they all seem to be either fake or badly formed)
50-59: 29
60-69: 11
70-79: 2
> 80: 0
That's probably not very representative, but it gives you an idea of what people tend to enter in to email fields if you are not too strict about what you accept in the form itself.
So, valid addresses across this sample appear to be between 5 and 39 characters, with the shortest valid address in the log at 8 characters. It's technically possible to have both shorter and longer ones but the chances of those being actual addresses are probably quite low.
All that said, I'd stick with the RFC anyway.
Juan Alfonso de Borja y Estevez
then by default you'll have a email-address of
juan_alfonso_de_borjy_y_estevez@company.com
This is just the first hit for "long spanish name" I found on google, but I have colleagues that have email-addresses that are that long or (in a few cases) even longer.