User IDs

Most sites give each user a unique ID, which is usually implemented as a sequential integer. Some sites don’t show this information at all (since it’s really just a behind-the-scenes primary key). Some sites “show” it in the URL as the unique identifier for a person. Some sites, Slashdot being the only one I can think of, display it prominently, as a sort of badge-of-honor for time on site.

I’ve been toying with the Facebook API just a little bit, to see what it would take to build a game. Facebook provides a tool to allow developers to tinker with API functions, one of them being friends.get, which returns an XML list of all the user IDs of your friends.

I don’t know how Facebook assigns user IDs. I do know from their API documentation that it’s now a 64-bit integer, which is kind of crazy. Most people just make it an INT. What fascinates me, though, is the range. I tend to think of myself as an early Facebook adopter. My user ID is 18601506, which we can infer as evidence that I was the 18,601,506th user to sign up for Facebook. I know a lot of sites that would be floored to have that many users.

But that’s nothing. The list of friends comes back in ascending order. The last entry is a bit over 1,800,000,000, which one could (perhaps erroneously) infer means that there are more than 1.8 billion accounts on Facebook, although that would include deleted rows, too, and this count would be utterly wrong if they stopped assigning numbers sequentially, which wouldn’t be a crazy thing to do with a partitioned database. The first entry on my friend list? It’s under 7,000. That’s a pretty amazing range: under 7,000 to over 1.8 billion?

One thought on “User IDs

  1. The id codes may not be exaactly sequential. They may be calculated via some sort of hash code. many years ago I did some work with a large organization that calculated their member IDs that way. You could not just guess a code an be sure that becasue it was in a given range that it would be a valid code. The software they used of course used this to do a first level of validation on IDs that were entered.

Leave a Reply

Your email address will not be published. Required fields are marked *