SQL Server 2005 计算列被持久化 [英] SQL Server 2005 Computed Column Is Persisted

查看:32
本文介绍了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"在此上下文中的意思是物理存储".

"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天全站免登陆