本文介绍了Facebook user_id:big_int,int或string?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



mySQL的无符号int的范围是0到4294967295(这是1个短小的 - 或者我的数学错误)
及其无符号大int的范围是0到18446744073709551615



int = 4个字节,bigint = 8个字节



OR



我是否将其存储为字符串?



varchar 10)=?字节



如何影响效率,我听说mysql句柄的数字远远超过字符串(性能明智)。那么你们推荐什么

解决方案

因为Facebook分配ID,而不是你,你必须使用BIGINTs。



Facebook不按顺序分配ID,我怀疑他们有分配号码的方式。



我最近修正了这个错误,所以这是一个真正的问题。



我会使它成为UNSIGNED,只是因为这是什么。 b
$ b

我将使用一个字符串。这使得比较痛苦,你的指标比他们需要的要大。


Facebook's user id's go up to 2^32 .. which by my count it 4294967296.

mySQL's unsigned int's range is 0 to 4294967295 (which is 1 short - or my math is wrong)and its unsigned big int's range is 0 to 18446744073709551615

int = 4 bytes, bigint = 8 bytes

OR

Do I store it as a string?

varchar(10) = ? bytes

How will it effect efficiency, I heard that mysql handle's numbers far better than strings (performance wise). So what do you guys recommend

解决方案

Because Facebook assigns the IDs, and not you, you must use BIGINTs.

Facebook does not assign the IDs sequentially, and I suspect they have some regime for assigning numbers.

I recently fixed exactly this bug, so it is a real problem.

I would make it UNSIGNED, simply because that is what it is.

I would not use a string. That makes comparisons painful and your indexes clunkier than they need to be.

这篇关于Facebook user_id:big_int,int或string?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 02:49