views:

134

answers:

2

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

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.

A: 

No. But there are certain conditions that must be met in order to create an index on a computed column: BOL - Creating Indexes on Computed Columns

Mitch Wheat
+2  A: 

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.

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.

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.

(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.

Damien_The_Unbeliever
I already edited my answer...
Mitch Wheat
+1 from me. .....
Mitch Wheat
Metric - performance improvements. It's a Name and a LoweredName (computed) column combination.
jameszhao00
So if I query the computed column (varchar type) for some value, will having it "persisted" make the query go any faster? Or does the index computation not depend on this persistence?
jameszhao00