Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am trying to understand is there any performance impact if I am trying to update a column which is the key column of a non-clustered index in SQL server 2008? For e,g

I have a column IsActive in the table TestTable. I have created a non clustered index on column IsActive. Now I am trying to update the value of the column IsActive through an update query like

UPDATE TestTable SET IsActive= 1 WHERE IsActive = 0

I need to understand will this perform better or not having the index on it will be better. I am asking his as reindexing takes place when index vales are updated. So will this reindexing have a impact on the query performance? Note : The table has excess of 100 million rows.

share|improve this question
2  
You have an non-clustered index on an IsActive column with values 0,1 on 100 million rows? –  Remus Rusanu Sep 26 '13 at 7:43
add comment

2 Answers

Modifying the value of a field used in an index will certainly take more time than modifying the value of a field not involved in an index. Having said that, the WHERE clause in your UPDATE statement could be used to speed the search for matching rows when the field in question is part of an index. In this example, where you have a boolean field present in 100 million rows means the selectivity of the field is so poor that a table scan will likely be required anyway. I would estimate that updating this particular field would be quicker if there was no index on it.

However, to answer your question of whether or not there will be performance impact on your system is really only answerable by you since there are a many other variables to consider such as storage speed, RAM availability, etc.

share|improve this answer
add comment

Yes

Updating a indexed column will take more time compare to an non indexed column because
>Index have its own cost like storage
>while you are updates or delete or insert on indexed column by default index must be 
updated first.

Here your table having millions of records that are being updated means millions of records will be updated first in INDEX as well. So it is going to harm the performance of update query.

"Index is an Database object That make search operation faster if it is build in well manner "

Thanks

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.