保留SQL Server 2005计算列 [英] SQL Server 2005 Computed Column Is Persisted

查看:65
本文介绍了保留SQL Server 2005计算列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表中有一些计算列,需要知道是否应将Is Persisted设置为true。有什么优势?有什么缺点吗? 持久是什么意思?

I have some computed columns in a table and need to know if I should set Is Persisted to true. What are the advantages? Are there any disadvantages? What does 'Is Persisted' mean?

推荐答案

持久在这种情况下表示物理存储。

"Persisted" means "stored physically" in this context.

这意味着计算值在插入(和更新)时计算一次并存储在磁盘上,因此不必在每次选择时都再次计算。

It means that the computed value is computed once on insert (and on updates) and stored on disc, so it does not have to be computed again on every select.

持久化还会导致插入和更新的性能下降,因为必须计算列,但会提高后续选择查询的性能。

Persisted also causes a performance penalty on insert and updates, since the column must be computed, but will increase the performance on subsequent select queries.

因此,这取决于您的使用模式以及采用的方法:如果您不经常更新,但查询很多,则应将persisted = true设置。

So, it depends on your usage pattern, which approach to follow: if you update infrequently, but query a lot, you should set persisted = true.

如果经常更新,或者您不关心检索性能,则应考虑将persisted = false设置为

If you update frequently, or if you do not care about retrieval performance, you should consider setting persisted = false

这篇关于保留SQL Server 2005计算列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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