Search code examples
phpmysqlprofile

What is best for a profile, a number or a name?


Most sites that have some sort of user profile will either do something like this:

profile.php?u=123445

or else:

profile.php?u=jason.Davis

So I am curious, would it be slower to use a name to lookup a profile with php/mysql vs. using a number to look up a profile record?


Solution

  • A string lookup would indeed probably be slower than a numeric one in probably every case. But the difference is so small it will never be noticed. Not until you have a really large number of users.

    But check out SO: They do both.

    http://stackoverflow.com/users/187606/pekka
    

    The number for blazing fast database access.

    The name for nice looks, and search engine visibility.

    No conflicts with two names, because the ID is what is used to search the record.

    I think that is the best of both worlds and the optimum.

    Requires URL rewriting, though.