Since I recently worked on the Fluff Grabber during my spring break, something caught my eye. Poking around in the database, I noticed there were some really long user IDs. It had about 15 digits. I found this incredibly strange. I prompt asked on twitter, does that mean there are more than 1 Quadrillion Facebook accounts?. Well, even I knew the answer to that question, but even so, it is seriously strange. A friend commented that it was more than just a user ID, it also contained a server address and did some other business.
Today, I looked this up. According to this post from May, 2009, Facebook was going to start implementing 64 bit user IDs.. There’s an even earlier post dating from October 2007 that mentions this, so it’s clear they always had plans to do this.
So what does that mean? Well, regular integers data types only have so much space. According to wikipedia, a signed integer can range from Ã¢Ë†â€™2,147,483,648 to +2,147,483,647 and an unsigned integer can range from 0 to +4,294,967,295. So, did Facebook really think they were going to eventually get four billion two hundred ninety-four million nine hundred sixty-seven thousand two hundred ninety-five users? Only if every person on earth made an account and then a third of those people made a second one.
However, that isn’t the range of 64 bit integers, not even close. Instead, we get the signed range of Ã¢Ë†â€™9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 and the unsigned range of 0 to +18,446,744,073,709,551,615. Assuming we’re working off the signed range, because PHP doesn’t really do unsigned integers, anyway, how many users is that? 9 Quadrillion. I think. It’s so large that Google cannot even tell me how that would be written out.
This impacted me slightly. I had no serious data loss, that I know off. I had to update my ID columns in my database to use BIGINT so that they could store 20 digits. Other people have been impacted by this because they actually coded Facebook applications.