Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the datatype of facebook userid

What datatype facebook uses to store userid, what should be that best data type for such field performance and scalability perspective.

If one uses int 4 bytes then i guess it ain't big enough, if 8 bytes int then how to assign random numbers to each user or same for string.

So what is the best way to give user a random id of fix length, keeping scalability and performance in mind?

like image 866
KKK Avatar asked Mar 04 '13 20:03

KKK


2 Answers

Good question. Facebook IDs can lead to problems as well as Tweet IDs. Both exceed the 32bit integer range. Depending on programming language specifics and the purpose (e.g. database, code, etc.) you may want to use float or double but in my experience casting them to string is satisfactory.

In MySQL, as tagged, provided is the BIGINT data type, which is large enough to store these IDs as numbers. The tricky part is when you read these values and process them in your program code. Those that are greater than the maximum allowed by system architecture / programming language may cause errors or be truncated leading to inconsistency.

If you want to use fixed length large IDs in MySQL, a good practice is to use the CHAR type and HEX format or you can use the UUID format.

like image 198
marekful Avatar answered Nov 03 '22 04:11

marekful


Use BIGINT(64) to store Facebook User IDs in MySQL Database Table.
Here you go: https://developers.facebook.com/blog/post/45/

like image 44
Faizan Noor Avatar answered Nov 03 '22 04:11

Faizan Noor