开发者

Is it still common to use an incremental number as identity on tables?

开发者 https://www.devze.com 2023-02-02 17:55 出处:网络
I am wondering because when you check ajax requests on facebook through firebug id\'s are a combination of characters and letter, not just an integer, I wonder if 开发者_运维技巧this are GUID\'s? and

I am wondering because when you check ajax requests on facebook through firebug id's are a combination of characters and letter, not just an integer, I wonder if 开发者_运维技巧this are GUID's? and is there any reason for doing this?


If dealing with huge datasets, constantly checking the last created object can become quite intensive (especially when talking distributed storage, etc). One alternative is to base the IDs on say the time, a random string, and more information, in order to create unique IDs less intensively without having to worry about collisions.

http://engineering.twitter.com/2010/06/announcing-snowflake.html provides some information on how Twitter deals with this.


The snowflake hyperlink points out an important decision: choosing an uncoordinated approach.

Twitter would theoretically have the option of coordinated ID generation, but this is not possible everywhere — think distributed, and above all, disconnected operations. Commit IDs in DVCS repositories like Git come to mind. That is where incremental numbers stop working and alternate, uncoordinated approaches are required such as hash sums of contents.


There are other approaches (but GUIDs tend to perform much worse than integers), but in answer to your question, using identities is still common and often the best approach from a performance and usability perspective. Each case must be analyzed individually. Without knowing what your design problems are, it is hard to say if they will work for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消