Saturday 2 November 2024

Column Store index scan/seek operator in SQL Server execution plan

The Columnstore Index Scan and Columnstore Index Seek operators appear in execution plans when SQL Server accesses data from a columnstore index. Columnstore indexes are optimized for analytical queries on large datasets and use a columnar storage format, which is different from traditional row-based storage.

Icon of this operator


See the example

For the demo here we are creating a table, creating column store index and inserting some records into this table.

CREATE TABLE sales
             
(
                          
saleid    INT,
                          
productid INT,
                          
saledate  DATE,
                          
quantity  INT,
                          
price     DECIMAL(10, 2)
             
);

 

DECLARE @a INT,
  
@b       INT;

SET @a=100000;

SET @b=1;

 

WHILE @b<=@a
BEGIN
  
INSERT INTO sales
              
(
                          
saleid,
                          
productid,
                          
saledate,
                          
quantity,
                          
price
              
)
  
SELECT @b,
         101
,
         
'2022-01-01',
         10
,
         100.00
  
SET @b=@b+1;
END;
-- Create a columnstore indexCREATE columnstore INDEX csix_sales ON sales (saleid, productid, saledate, quantity, price);

Inserted 100k records into this table.

Let’s run the below query.


See the execution plan

No comments:

Post a Comment

If you have any doubt, please let me know.

Popular Posts