SQL Server:我可以创建一个“合成”吗?没有索引或约束检查开销的关系?
我希望做的是确保在数据库模式中维护外键关系,但出于性能原因,不强制执行约束或产生任何索引开销。其目的纯粹是为了记录关系。这通常被称为“综合关系”。
What I wish to do is ensure that the foreign key relation is maintained in the database schema but for performance reasons, not enforce the constrain or incur any indexing overheads. It's purpose is purely to document the relationship. This is typically referred to as a "synthetic relation".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SQL Server 中的 FK 没有索引开销,因为它不为它们创建默认索引。
您可以通过禁用 FK 来实现您想要的有关约束检查的功能。
除了确保数据完整性之外,优化器还可以使用外键约束来改进查询计划(参考:第 9 点)
您是否已确定 FK 导致了您的案例中的特定性能问题?
There is no indexing overhead with FKs in SQL Server as it creates no default indexes for them.
You can achieve the functionality you want with regards to constraint checking by disabling the FK.
As well as ensuring data integrity foreign key constraints can also be used by the optimiser to improve query plans (Ref: Point 9)
Have you identified the FK as causing a specific performance issue in your case?