I've table, example as
Id int primary key(clustered index) Name varchar(255)not null (non-clustered index) .. .. Other columns
I execute stored procedur as
update table1 set table1.Name=isnull(@Name,table1.Name) ,( updating other columns) where Id=@Id;
if i change stored procedure as
update table1 set ( updating other columns) where Id=@Id;
i saw Cost:15%
I need to change this procuder for two situation when
- table1.Name= @Name
- table1.Name <> Name.
In first case table1.Name doesn't change value or index doesn't update and clustered index update cost 15%;
in second case table1.Name changes value and clustered index update cost 50%.
Why index is updating when update a equal value?
i can't select "Name" and compare befor updatings
I know that create varchar column index isn't good idea
maybe anybody can help with trigger if it can help with this issue?