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?
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.
Use BIGINT(64) to store Facebook User IDs in MySQL Database Table.
Here you go: https://developers.facebook.com/blog/post/45/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With