What's the average length of an email address?

Janusz Slota - Tue 05 May 2009 - email, mysql, php, postgres

This question always comes up, when you have to design new table in database to store email addresses. Is VARCHAR(30) long enough? Or maybe you should use VARCHAR(255) or maybe TEXT as I've seen in some projects?

My live database, which I've used for this test contains 92298 valid email addresses, verified with the Pear Validate class with domain checking.

<?php
if(Validate::email($email,true))
{
    // add to database
    return true;
}
else
{
    // return error
    return false;
}

It means, if the email address is in this database - it is real and correct, otherwise the field is empty. So to make sure not to include empty fields, I've issued following query:

SELECT count(*), length(email) as size FROM customer WHERE email LIKE '%@%' GROUP BY size ORDER BY size;

This query returns set of values, which I've used to create this chart (with OpenOffice.org Calc).

Average emial address length

As you can see majority of email addresses are around 13 to 34 characters long. To store email addresses I've used VARCHAR (255) but as you can see VARCHAR(50) is enough.

The answer: VARCHAR(50) should do.