Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

mysql

profile

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?

like image 780
JasonDavis Avatar asked Dec 24 '09 02:12

JasonDavis


2 Answers

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.

like image 73
Pekka Avatar answered Sep 28 '22 22:09

Pekka


The name will be more readable and easier to debug, but names are not guaranteed to be unique so it will need to be augmented by a uniqifier (I believe this is actually a word, used in unification) to e.g. append digits to the end of the name.

like image 24
Larry Watanabe Avatar answered Sep 29 '22 00:09

Larry Watanabe