SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Creating indexes on computed columns


Creating indexes on computed columns

Author
Message
daveb87
daveb87
SSC Eights!
SSC Eights! (829 reputation)SSC Eights! (829 reputation)SSC Eights! (829 reputation)SSC Eights! (829 reputation)SSC Eights! (829 reputation)SSC Eights! (829 reputation)SSC Eights! (829 reputation)SSC Eights! (829 reputation)

Group: General Forum Members
Points: 829 Visits: 537
Please check the answers before posting a question. People use the QofD as a way to learn or to refresh the memory on a given topic. Bad and incorrect questions just waste time.



Christian Buettner-167247
Christian Buettner-167247
SSCrazy Eights
SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)

Group: General Forum Members
Points: 8479 Visits: 3889
Hi Steve,

Steve Eckhart (9/30/2010)
Actually, if you read carefully, an index on a computed column CAN include multiple rows and columns from other tables.

Can you give an example of multiple rows? I doubt it.
And for the columns from other tables -> That is per definition non-deterministic.
http://msdn.microsoft.com/en-us/library/aa214775(SQL.80).aspx

As long as one of the following four conditions are true, then you can use the computed column in an index.

Now that does not say "exactly" one, it means one or more. It does not tell you which combinations would be deterministic and precise.

Best Regards,

Chris Büttner
gajapathy
gajapathy
SSC Veteran
SSC Veteran (297 reputation)SSC Veteran (297 reputation)SSC Veteran (297 reputation)SSC Veteran (297 reputation)SSC Veteran (297 reputation)SSC Veteran (297 reputation)SSC Veteran (297 reputation)SSC Veteran (297 reputation)

Group: General Forum Members
Points: 297 Visits: 18
Hi,

As others did, I have selected choices 1,2 and 4 and left 3 unchecked. If this is wrong then MSDN itself wrong. Please refer the link
http://msdn.microsoft.com/en-us/library/ms189292.aspx

I am not responding to gain the point, but to get exactly which is correct answer.

Regards,
hkamal.infoedge
hkamal.infoedge
SSC-Addicted
SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)

Group: General Forum Members
Points: 426 Visits: 311
No column reference pulls data from multiple rows. For example, aggregate functions such as SUM or AVG depend on data from multiple rows and would make a computed_column_expression nondeterministic.
Steve Jones
Steve Jones
SSC Guru
SSC Guru (327K reputation)SSC Guru (327K reputation)SSC Guru (327K reputation)SSC Guru (327K reputation)SSC Guru (327K reputation)SSC Guru (327K reputation)SSC Guru (327K reputation)SSC Guru (327K reputation)

Group: Administrators
Points: 327801 Visits: 20091
The answer choices have been corrected and points awarded back.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
gchornenkyy
gchornenkyy
SSC-Addicted
SSC-Addicted (480 reputation)SSC-Addicted (480 reputation)SSC-Addicted (480 reputation)SSC-Addicted (480 reputation)SSC-Addicted (480 reputation)SSC-Addicted (480 reputation)SSC-Addicted (480 reputation)SSC-Addicted (480 reputation)

Group: General Forum Members
Points: 480 Visits: 402
Just wonder about user data meaning. If I have user defined table it means that it keeps user defined data.
Here the very simple example of filtered index on computed column

CREATE TABLE [dbo].[t2](
[c2] [int] NULL,
[comp_col] AS ([c2]*(2)) PERSISTED
) ON [PRIMARY]

GO

create index ix_comp_col on t2 ( comp_col )
where c2 > 4

GO

So?
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)

Group: General Forum Members
Points: 143621 Visits: 18649
Steve Jones - Editor (9/30/2010)
The answer choices have been corrected and points awarded back.


Thanks for fixing that - for those of us answering late.

Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw
Learn Extended Events

Tom Thomson
Tom Thomson
SSC Guru
SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)

Group: General Forum Members
Points: 50433 Visits: 13157
Two interesting things here:

The first is that the BoL page referenced in the explanation has incorrect information on it: it quite clearly says
A computed_column_expression is deterministic when one or more of the following is true:
where actually all need to true, not just one.

The second is that the corrected answer may still be wrong: as someone pointed out in an earlier comment, the BoL page says (twice) that a computed column which is imprecise can be used in an index provided it is persisted. So perhaps item 1 should not be in the list of answers to be checked.

Tom

Konstantin Reu
Konstantin Reu
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2887 Visits: 816
There is error. Correcty answer is 1 and 2. But 4 "Has no system data access or user data access." is correct when computed column marks as persisted and based on function, that will not have access to user/system tables.

Does question "Creating indexes on computed columns" contain any about persisted ? - No.... I don't won 1 point.

MS SQL 2008 MCITP x 3
MS SQL 2012 MCSE x 2
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search