SQL Server计算列是否需要“持久性”?为了有效地索引它? [英] Does a SQL Server Computed Column require "persistence" in order for it to be indexed efficiently?

查看:929
本文介绍了SQL Server计算列是否需要“持久性”?为了有效地索引它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SQL Server计算列是否需要持久性以便有效地编制索引?

Does a SQL Server Computed Column require "persistence" in order for it to be indexed efficiently?

这是一个名称和一个LoweredName(计算)列组合。因此我不认为它涉及MSDN文章中提到的精确内容。

It's a Name and a LoweredName (computed) column combination. So I don't believe it deals with the precision stuff mentioned in a MSDN article.

推荐答案

与Mit​​ch相反已经声明,您不需要为要创建的索引保留一个列(MSDN文章指出的是,如果计算列不确定,则必须将其标记为持久化之前它可以被考虑包含在索引中。

Contrary to what Mitch has stated, you don't need a column to be persisted for an index to be created (what the MSDN article states is that, if the computed column is not deterministic, then it has to be marked persisted before it can be considered for inclusion in an index.

关于原始问题,我希望索引效率与任何一个一样好其他专栏 - 我们使用什么指标来提高效率?我当然不希望它占用更多空间。在INSERT / UPDATE期间会有一些计算开销,但无论列是否标记为持久化。

As to the original question, I'd expect the index efficiency to be as good as for any other column - what metric are we using for the efficiency? I certainly wouldn't expect it to take up more space. There would be some computation overhead during INSERT/UPDATE, but you'd have that whether or not the column was marked as persisted.

在通过索引进行查询时应该没有任何区别 - 索引结构本身的构造是相同的,无论这是真正的列,还是持续的计算机ted列,或者一个未加载的计算列。

There shouldn't be any difference when it comes to querying via the index - the index structure itself would be constructed the same whether this was a real column, a persisted computed column, or an unpersisted computed column.

(希望最终编辑) - 如果你检索,可能会有很小的性能损失计算列,与例如相比,计算本身是昂贵的网络开销或其他I / O成本。但在转换为小写的情况下,我不希望能够注意到它。

(Hopefully final edit) - there may be a small performance hit if you're retrieving the computed column, and the computation itself is expensive, when compared with e.g. the network overhead, or other I/O costs. But in the case of converting to lower case, I'd not expect to be able to notice it.

这篇关于SQL Server计算列是否需要“持久性”?为了有效地索引它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆