Posted in Development

SQL Server – Columnstore Index creation error: A columnstore index cannot have INCLUDED columns

Hi friends, in my previous blog we learnt that sparse column cannot be part of columnstore index. In this blog we will discuss another limitation of columnstore index which is INCLUDE clause is not allowed while creating columnstore index.

Now, let’s create a test table and then we will try to create a nonclustered columnstore index using INCLUDE clause:

CREATE TABLE Test_Include

(

                ID INT,

                FirstName VARCHAR(10) NOT NULL,

                MiddleName VARCHAR(10),

                LastName VARCHAR(10) NOT NULL

)

Now let’s create a nonclustered columnstore index on this table using below script:

CREATE NONCLUSTERED COLUMNSTORE INDEX ix_TestInclude

ON Test_Include (ID, FirstName, LastName)

INCLUDE (MiddleName)

When we execute the above script it gives us error:

CREATE INDEX statement failed because a columnstore index cannot have included column. Create the columnstore index on the desired columns without specifying any included columns.’

 CS_2

Also, from the error message itself we come to know that included columns are not allowed in columnstore index.

Drop the table –

DROP TABLE Test_Include

So friends, this is another one of the limitation of nonclustered columnstore index. Hope you like it 🙂

Advertisements
Posted in Development

SQL Server – Columnstore Index creation error: A columnstore index cannot be created on a SPARSE column

Hi friends, as we know that in SQL Server 2012 a new feature Columnstore index was introduced which made a great change in area of performance optimization like reducing I/O. From SQL server 2012 to 2016 there were many changes made in columnstore index. In SQL Server 2012 only nonclustered columnstore index were introduced.

In the next few blogs we will discuss some limitations of columnstore index.

What is columnstore index?

From BOL: columnstore index is a technology for storing, retrieving and managing data by using a columnar data format, called a columnstore.

Now, let’s create a test table with a SPARSE column property in it and then we will try to create a nonclustered columnstore index including that column:

CREATE TABLE Test_Sparse

(

                ID INT,

                FirstName VARCHAR(10) NOT NULL,

                MiddleName VARCHAR(10) SPARSE,

                LastName VARCHAR(10) NOT NULL

)

Sparse column is used to handle NULL or ZERO values as it doesn’t take any space.

Now let’s create a nonclustered columnstore index on this table using below script:

CREATE NONCLUSTERED COLUMNSTORE INDEX ix_TestSparse

ON Test_Sparse (ID, FirstName, MiddleName, LastName)

When we execute the above script it gives us error:

CREATE INDEX statement failed because a columnstore index cannot be created on a sparse column. Consider creating a nonclustered columnstore index on a subset of column that does not include any sparse column.’

CS_1

From the error message itself we come to know that sparse column cannot be part of columnstore index.

Drop the table –

DROP TABLE Test_Sparse

So friends, this is one of the limitation of nonclustered columnstore. We will learn some more limitations of columnstore index in my next blog.

Hope you like it J