最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

为什么aspnet

SEO心得admin86浏览0评论
本文介绍了为什么aspnet_users使用GUID的ID,而不是递增诠释?奖励积分的帮助关于延长用户字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

为什么aspnet_users使用GUID的ID,而不是递增INT?

Why does aspnet_users use guid for id rather than incrementing int?

也没有任何理由不给其他表使用作为主键?这感觉有点奇怪,因为我知道大多数的应用程序,我在过去曾与仅仅使用普通INT系统。

Also is there any reason no to use this in other tables as the primary key? It feels a bit odd as I know most apps I've worked with in the past just use the normal int system.

我也即将开始使用此ID匹配的扩展信息表,额外的用户preFS等我使用一个链接表一个GUID,并在其中一个int也在考虑,但决定为我不认为我真的需要有用户ID为公众诠释。

I'm also about to start using this id to match against an extended details table for extra user prefs etc. I was also considering using a link table with a guid and an int in it, but decided that as I don't think I actually need to have user id as a public int.

虽然我很想有INT(感觉容易做到用户查找等stackoverflow/users/12345/user-name),因为我只是将不得不用户名,我不认为我需要随身携带此项目,incure查找的额外的复杂性时,我需要找到一个用户INT。

Although I would like to have the int (feels easier to do a user lookup etc stackoverflow/users/12345/user-name ) , as I am just going to have the username, I don't think I need to carry this item around, and incure the extra complexity of lookups when I need to find a users int.

感谢您与任何这任何帮助。

Thanks for any help with any of this.

推荐答案

这确保整个系统断开独特性。这可能需要与另一previously无关的数据存储可能会遇到碰撞到接口的任何数据存储 - 例如它们都使用了 INT 来识别用户,现在我们必须要经历一个复杂的解析过程来选择相应的冲突的那些新的ID和更新所有引用。

It ensures uniqueness across disconnected systems. Any data store which may need to interface with another previously unconnected datastore can potentially encounter collisions - e.g. they both used int to identify users, now we have to go through a complex resolution process to choose new IDs for the conflicting ones and update all references accordingly.

的缺点在SQL中使用标准的唯一标识符(与NEWID())作为主键是GUID是不连续的,所以作为新行创建它们插在物理数据库页面的一些任意位置,而不是追加到末尾。这导致的严重的页碎片对具有任何实质性的插入速率系统。它可以通过使用NEWSEQUENTIALID()代替进行校正。我讨论过这个在more这里详细的。

The downside to using a standard uniqueidentifier in SQL (with newid()) as the primary key is that GUIDs are not sequential, so as new rows are created they are inserted at some arbitrary position in the physical database page, instead of appended to the end. This causes severe page fragmentation for systems that have any substantial insert rate. It can be corrected by using newsequentialid() instead. I discussed this in more detail here.

在一般情况下,它的最好的做法要么使用NEWSEQUENTIALID()为您的GUID主键,或只是不使用的GUID的主键。你总是可以有辅助索引的列存储一个GUID,你可以用它来保持你的独特引用

In general, its best practice to either use newsequentialid() for your GUID primary key, or just don't use GUIDs for the primary key. You can always have a secondary indexed column that stores a GUID, which you can use to keep your references unique.

发布评论

评论列表(0)

  1. 暂无评论