A question about clustered indexes forcing rebuild of non-clustered indexes.

So I'm reading http://www.sql-server-performance.com/tips/clustered_indexes_p2.aspx and I come across this:

When selecting a column to base your clustered index on, try to avoid columns that are frequently updated. Every time that a column used for a clustered index is modified, all of the non-clustered indexes must also be updated, creating additional overhead. [6.5, 7.0, 2000, 2005] Updated 3-5-2004

Does this mean if I have say a table called Item with a clustered index on a column in it called itemaddeddate, and several non-clustered indexes associated with that table, that if a record gets modified and it's itemaddeddate value changes, that ALL my indexes on that table will get rebuilt? Or is it referring to the table structure changing?

If so does this "pseudocode" example also cause this to occur:

sqlstring="select * from item where itemid=12345"

rs.open sqlstring, etc, etc, etc

rs.Fields("ItemName")="My New Item Name"

rs.Fields("ItemPrice")=1.00

rs.Update

Note I didn't explicitly change the value of rs.fields("ItemAddedDate")...does rs.Fields("ItemAddedDate")=rs.Fields("ItemAddedDate") occur implicitly, which would force the rebuild of all the non-clustered indexes?


Flames are for BBQ'ing.
http://weblogs.asp.net/RyanSmith
0
RyanSJedi
9/18/2007 9:46:41 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

4 Replies
830 Views

Similar Articles

[PageSpeed] 1
Get it on Google Play
Get it on Apple App Store

Since it's been a while and no one responded, I thought I'd throw my 2 cents in.  I'm not sure the link you posted is correct, but it might be.  It would depend on whether SQL Server attempts to maintain clustering when you update a clustered index, and I don't know the answer to that.  For example, suppose you have a clustered index on name and update someone from "AAAA" to "ZZZZ".  This would change his position in the table, which is to say it would change the page number of that row (since it would move from the beginning of the DB to the end), which would mean that all other indexes would have to be updated too. 

 This depends entirely on whether SQL actually tries to maintain the clustering in real time, and I don't know the answer to that.  With other products I've worked with, the DB just lets the data get out of cluster and you have to rebuild them from time-to-time.


- David

Please click "Mark as Answer" on all posts that help you.
0
dbland07666
9/24/2007 2:42:36 PM

I posted this question on sql-server-performance and got a reply: http://sql-server-performance.com/Community/forums/p/23274/132088.aspx#132088


- David

Please click "Mark as Answer" on all posts that help you.
0
dbland07666
9/24/2007 6:00:38 PM

dbland07666:

I posted this question on sql-server-performance and got a reply: http://sql-server-performance.com/Community/forums/p/23274/132088.aspx#132088

And that would be me ..Smile

***********************
Dinakar Nethi
Life is short. Enjoy it.
***********************
0
ndinakar
9/24/2007 6:25:27 PM

I figured!


- David

Please click "Mark as Answer" on all posts that help you.
0
dbland07666
9/24/2007 6:36:41 PM
Reply:

Web resources about - A question about clustered indexes forcing rebuild of non-clustered indexes. - asp.net.sql-datasource

Resources last updated: 12/6/2015 2:30:35 PM