简体   繁体   中英

best way to store Google user-ID value in mysql and java

google user id from token eg:

"sub": "110169484474386276334",

Source

Can't seem to find the definition of this number there example is 21 chars long so even a unsigned bigint cant handle it in mysql and a long cant handle it in java,

currently i'm storing it as a string but i feel this may be inefficient, especially as most of my DB work minimum of 50% is going to be lookups on these numbers i want it to be as index friendly as possible, and i have a gut feeling a index on a number will be faster than a index on a string. i have assumed from the limited documentation that there are always numbers.

currently using varchar . thanks

Keep it as a string.

Unless you have a very big user base and storage space is a big concern, optimizations like this will most likely cause more trouble that good.

Just one example why storing the id as a number could be a problem: Ids with leading zeros , which will be disregarded if you treat it as a number. 0100 is not necessarily the same id as 100 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM