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


CI and NC index on same column is it sugestable ?


CI and NC index on same column is it sugestable ?

Author
Message
sql.lanka
sql.lanka
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 470
Hi,

I have a question regarding indexes.

If i have cluster and NC index on same column,does it degrade performance on DML statements ? any advantage on select statements.

Is it good to have both indexes on same column ?
Grant Fritchey
Grant Fritchey
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39689 Visits: 32639
In the overriding majority of cases, no, this is a serious waste of resources. Most queries will only ever reference the clustered index, especially if they need to get any columns from the data that is stored there. You might find some odd cases such as a COUNT(*) or something like that where no other columns are ever referenced that the non-clustered index, because it will be smaller, with fewer pages, than the clustered index (assuming a table with multiple columns of data). But those are going to be very tiny and obscure exceptions. In the mean time, you're maintaining a second set of information on your storage system for every INSERT/UPDATE/DELETE that will never be used.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Gianluca Sartori
Gianluca Sartori
SSCrazy Eights
SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)

Group: General Forum Members
Points: 9844 Visits: 13350
does it degrade performance on DML statements ?
Is it good to have both indexes on same column ?


In general, it's not a good thing. In case of a clustered index, the index is the data in the table. In case of a nonclustered index, the index contains a copy of the data. Each time you write to the table, you write multiple copies of the data and that can hurt performance.

any advantage on select statements?


Generally speaking very little advantage.
The only advantage could come from the nonclustered index being smaller than the clustered index when a scan is performed. Often, this advantage is eliminated by the subsequent lookups needed to fetch the columns not included in the nonclustered index.

Bottom line: there are some cases where a nonclustered index and a clustered index on the same key are beneficial, but it's very unlikely.

--Gianluca Sartori

How to post T-SQL questions
spaghettidba.com
@spaghettidba
sql.lanka
sql.lanka
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 470
Thanks for your reply
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