Click here to monitor SSC
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
SSChasing Mays
SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)

Group: General Forum Members
Points: 649 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
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2953 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-Enthusiastic
SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)

Group: General Forum Members
Points: 192 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-Dedicated
SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)

Group: Administrators
Points: 36355 Visits: 18756
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 (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)

Group: General Forum Members
Points: 420 Visits: 377
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-Insane
SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)

Group: General Forum Members
Points: 21151 Visits: 18259
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

TomThomson
TomThomson
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10781 Visits: 12019
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.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2650 Visits: 755
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