ASP.NET 成员资格提供程序、用户 ID GUID 和磁盘空间

发布于 2024-07-21 01:43:51 字数 218 浏览 2 评论 0原文

我当前正在使用 ASP.NET 的 SQL 成员身份提供程序,该提供程序使用 GUID 作为用户 ID。 我的应用程序有几个自定义表,这些表与用户表有外键关系,我担心标准提供程序使用 GUID 作为用户 ID 的磁盘空间和性能影响。

有没有人遇到与此相关的空间/性能问题?如果有,人们是否已经实施了自定义方法来解决这个问题?

任何见解或建议将不胜感激。

谢谢

I'm currently using the SQL Membership provider for ASP.NET, which uses GUIDs for the User ID. My application has several custom tables that have foreign key relations back to the User table and I'm concerned about the disk space and performance implications of the standard provider's use of GUIDs for user ID.

Has anyone run into space / performance issues related to this and if so are there custom approaches that people have implemented to address this?

Any insight or suggestions would be most appreciated.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

堇色安年 2024-07-28 01:43:51

我怀疑您是否会因为使用 GUID 而不是 INT 类型而遇到任何空间问题。 我要警告您的一件事是,您可能会想在数据库中的 GUID 列上创建聚集索引。 不要这样做。 默认情况下,GUID 是随机的,将随机数据插入具有聚集索引的列会导致一些问题。 您可能知道,集群意味着物理存储顺序。 因此,当您插入新的随机值 (GUID) 时,通常必须将该行插入到表的中间。 这可能会导致索引大量碎片。

我的建议是创建一个表,将 GUID 链接到 INT 值(如果您期望有很多用户,则为 BIGINT),然后在其他地方使用 INT。 就像费明刚才说的那样。

I doubt you'll have any space issues as a result of using GUIDs rather than INT types for example. One thing I will warn you about is that you might be tempted to create clustered indexes on the GUID columns in the database. DO NOT DO THIS. By default, GUIDs are random, and inserting random data into a column that has a clustered index causes a few issues. Clustered, as you might know, means IN PHYSICAL STORAGE SEQUENCE. So when you insert a new random value (GUID) that row usually has to be inserted into the middle of the table. This can lead to massively fragmented indexes.

My advice would be to create a table that links the GUIDs to INT values (BIGINT if you expect that many users) and then use the INT everywhere else. Like Fermin just said.

仙气飘飘 2024-07-28 01:43:51

您是否没有一个将 GUID 映射到整数值的自定义表,然后您可以在自定义表中使用该整数?

UserId guid
FriendlyUserId int //use this as FK in other tables?

Could you not have a custom table which maps the GUID to an integer value which you can then use the integer in custom tables?

UserId guid
FriendlyUserId int //use this as FK in other tables?
阳光下的泡沫是彩色的 2024-07-28 01:43:51

如果您使用的是 SQL Server 2005,您可能需要查看 NewSequentialId() 方法。 Eric Swann 提供了 很好地概述了它与会员提供商的使用情况。 还有一篇好文章介绍了使用顺序 GUID 的好处超过默认的随机数。 这是文章中的性能比较摘录......

                  [Reads] [Writes]  [Leaf Pages] [Avg Page Used] [Avg Fragmentation] [Record Count]
  IDENTITY(,)     0        1,683      1,667     98.9%            0.7%               50,000
  NEWID()           0      5,386      2,486     69.3%           99.2%               50,000
  NEWSEQUENTIALID() 0      1,746      1,725     99.9%            1.0%               50,000

If you are using SQL Server 2005, you may want to look at the NewSequentialId() method. Eric Swann provides a good overview of its use with the Membership provider. There is also a nice article on benefits of using sequential GUIDs over the default random ones. Here is a performance comparison excerpt from the article...

                  [Reads] [Writes]  [Leaf Pages] [Avg Page Used] [Avg Fragmentation] [Record Count]
  IDENTITY(,)     0        1,683      1,667     98.9%            0.7%               50,000
  NEWID()           0      5,386      2,486     69.3%           99.2%               50,000
  NEWSEQUENTIALID() 0      1,746      1,725     99.9%            1.0%               50,000
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文