Tuesday, July 29, 2014

Columnstore Index in SQL Server 2014



A Columnstore index is a technology which we use to store, select and managing data by using a columnar data format, called a columnstore. SQL Server supports both clustered and nonclustered columnstore indexes. Both use the same in-memory columnstore technology,
But they do have differences in purpose and in features they support.
SQL server 2014 support updateable clustered columnstore index comparing to SQL server 2012 Non updateable clustered columnstore Index.

In columnstore data is logically organized data as table in rows and column format but physically store data in column wise format.



Example:
CREATE TABLE tbl_ProductColumnStore(
ProductId [int] NOT NULL,
OrderDateId [int] NOT NULL,
Quantity [int] NOT NULL,
RecNo [int] NOT NULL);
GO

CREATE CLUSTERED COLUMNSTORE INDEX CCI_tbl_EmployeeColumnStore ON tbl_ProductColumnStore;
GO

-- We can have only one columnstore index on a table, if we create additional index it show error.

CREATE NONCLUSTERED COLUMNSTORE index NCCI_tbl_EmployeeColumnStore ON tbl_ProductColumnStore(ProductId);
GO

Error:
Msg 35303, Level 16, State 1, Line 14
CREATE INDEX statement failed because a nonclustered index cannot be created on a table that has a clustered columnstore index. Consider replacing the clustered columnstore index with a nonclustered columnstore index.


Some Key points on Clustered ColumnStore:
1 Has storage on entire table.
2 No key columns. All columns are included columns.
3 Has only one index on the table.
4 Can be configured to use columnstore or columnstore archival compression.
5 Columns does not physically stored in a sorted order. Instead, it stores data to improve compression and performance.

Some Key points on Non Clustered ColumnStore:
1 Can index a subset of columns in the clustered index
2 Requires extra storage to store a copy of the columns in the index.
3 Is updated by rebuilding the index or switching partitions in and out.
4 Can be combined with other indexes on the table.
5 Can be configured to use columnstore or columnstore archival compression.
6 Does not physically store columns in a sorted order. Instead, it stores data to improve compression and performance. Pre-sorting the data before creating the columnstore index is not required, but can improve columnstore compression.



No comments :

Post a Comment