ASP.NET 成员资格提供程序、用户 ID GUID 和磁盘空间
我当前正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我怀疑您是否会因为使用 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.
您是否没有一个将 GUID 映射到整数值的自定义表,然后您可以在自定义表中使用该整数?
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?
如果您使用的是 SQL Server 2005,您可能需要查看
NewSequentialId()
方法。 Eric Swann 提供了 很好地概述了它与会员提供商的使用情况。 还有一篇好文章介绍了使用顺序 GUID 的好处超过默认的随机数。 这是文章中的性能比较摘录......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...