The Index Update operator in SQL Server is used in execution plans when performing an UPDATE operation on a table that has indexes. This operator modifies index entries when indexed columns are updated, ensuring that the index remains consistent with the table's current data.
The Index Update
operator appears in an execution plan when:
Ø An UPDATE statement modifies a column that is part of a non-clustered or clustered index.
Ø SQL Server needs to adjust the index entries to reflect the changes in the indexed column(s).
Icon of index update
operator
See the example
For the demo we are creating a table and non-cluster index
and inserting some records in this table.
CREATE TABLE Products ( ProductID INT PRIMARY KEY, ProductName VARCHAR(50), Price DECIMAL(10, 2) ); -- Create a non-clustered index on the Price column CREATE INDEX IX_Products_Price ON Products(Price); VALUES (1, 'Laptop', 1200.00), (2, 'Smartphone', 700.00), (3, 'Tablet', 300.00); |
See the records in the table
Now updating the records in this table
UPDATE Products SET Price = 700.00 WHERE ProductID = 2; |
Running this query
See here 2 rows affected. One update in the table and other
update on index.
See the execution plan
No comments:
Post a Comment
If you have any doubt, please let me know.