What is non clustered column store index in SQL Server?
Column store index is a new feature introduced in SQL Sever 2012.In Non clustered column store index data is stored as column.Column order is not important in column store index.In this non clustered column store index we don’t have traditional row execution mode instead of that,we have batch execution mode.This improves query execution.Batch execution mode executes several rows at a time as a batch.This reduces CPU consumption.
In column store execution, only columns that query needs will be read.This reduces I/O and memory utilization.
We cant have Unique,Primary or Foreign key constraints in column store index and also it does not have feature like INCLUDE.Once we have created the Non clustered column store index for a table,we can’t update the table with new values because the table is READ-ONLY.We could have only one non clustered column store index.Column store index could have only 1024 columns.And we don’t have clustered column store index only Non clustered is available.
This column store index uses the benefits of segment elimination based on some conditions.It gives faster performance for common data warehousing queries.
Create a Column Store Index in SQL Server by using below steps.
1.In Object Explorer, expand Tables, right click -> Indexes and click New Index. Select non clustered column store index .
2.Add the column store columns.
- select the table column to be added to the index.
- Selected Column store column will be added.
3.Set the options by selecting options from select page.In that give the value for Max degree of parallelism as greater than or equal to (2) to have batch execution.
Set other extended properties you need by clicking extended properties node.
4.Non clustered column store index is successfully created.
NONCLUSTERED COLUMNSTORE index without options:
Create database product;
CREATE TABLE Test
(ID [int] NOT NULL,
RecDate [int] NOT NULL,
DelDate [int] NOT NULL,
ExtDate[int] NOT NULL);
CREATE CLUSTERED INDEX cl_test ON Test (ID);
CREATE NONCLUSTERED COLUMNSTORE INDEX csindex_test ON Test (RecDate, DelDate, ExtDate);
NONCLUSTERED COLUMNSTORE index with options:
CREATE NONCLUSTERED COLUMNSTORE INDEX csindex_test ON Test
(RecDate, DelDate, ExtDate)
(DROP_EXISTING = ON, MAXDOP = 2)