Saturday 2 November 2024

Index Insert operator in SQL Server execution plan

 The index insert operator in SQL server execution plan is responsible for inserting rows into an index on generally cluster or non-cluster index. This operator is commonly seen when insert, update or marge operation on the table which have index. When we are inserting, updating or marge records on this table two things happen one, Inserting or updating records into the table at the same time need to update the index pages.

Icon of Index Insert Operator

See the example

Creating a table and an index on the 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);

Table and index created.

Now inserting some records into this table.

INSERT INTO Products (ProductID, ProductName, Price)

VALUES (1, 'Laptop', 1200.00),

       (2, 'Smartphone', 700.00),

       (3, 'Tablet', 300.00);

Run this script and see the execution plan

No comments:

Post a Comment

If you have any doubt, please let me know.

Popular Posts