SQL SERVER – Updating Data into ColumnStore Index with SQL Server 2012

SQL SERVER - Updating Data into ColumnStore Index with SQL Server 2012 columnstore-500x375 Off late I have been writing tons of content working with SQL Server 2016. Some of the cool capabilities was to introduce the ability to update a ColumnStore index. This was also covered in the SQL SERVER 2016: Updating Non-Clustered ColumnStore Index Enhancement earlier. One of the readers asked me an interesting question about being inside SQL Server 2012 and they wanted to write / update their data on the ColumnStore enabled system and what was the process for them. The email started saying they were getting the following error.

Msg 35330, Level 15, State 1, Line 1
INSERT statement failed because data cannot be updated in a table with a columnstore index. Consider disabling the columnstore index before issuing the INSERT statement, then rebuilding the columnstore index after INSERT is complete.

The error message recommends a ‘workaround’, but rebuilding the column store index for updates may be prohibitively expensive. This is typically what most of you will get by working with SQL Server 2012 and ColumnStore Indexes. I was asked for possible solutions / processes so that we can do this in an efficient manner. I wrote back with the following recommendation.

Solarwinds

For the DW and BI scenarios that column store indexes are targeting, there is a much better solution: use table partitioning. With SQL Server 2012, the limit of maximum 1000 partitions per table has been increased to 15000 partitions; and with this new limit, one can configure the ETL process to update every day into a new partition and still retain many years of data. The ETL process can upload the daily data into a staging table, create a columnstore index on the staging table, then use the fast ALTER TABLE … SWITCH operation to ‘switch in’ the new data.

Other methods to update a columnstore index include:

  1. Disable or drop the columnstore index. You can then update the data in the table. If you disable the columnstore index, you can rebuild the columnstore index when you finish updating the data, for example:
ALTER INDEX myColumnStoreIndex ON myDWtable DISABLE;

— update the data —

ALTER INDEX myColumnStoreIndex ON myDWtable REBUILD;

Now the column store index is ready to use again.

  1. Switch a partition from the table with the column store index into an empty staging table. If there is a column store index on the staging table, disable the column store index. Perform any updates. Build (or rebuild) the column store index. Switch the staging table back into the (now empty) partition of the main table.

These are classic scenarios and well documented by a number of folks. I would like to understand if you are using SQL Server 2012 version with ColumnStore? Are you handling in one of the above mentioned processes? I would love to hear if you are using any other techniques. Please use the comments section below to explain the same.

Reference: Pinal Dave (https://blog.sqlauthority.com)

Solarwinds
, , ,
Previous Post
SQL SERVER – ShowPlan XML Additions for ColumnStore Indexes
Next Post
SQL SERVER – Identify Table Where Clustered Index is Not a Primary Key – DMV

Related Posts

2 Comments. Leave new

  • I’m using the 2012 column store and it’s a pain in the ass. The rebuilding require a large amount of memory and I have to close down almost everything on my machine to free up enough. You might think 8GB and 65% in use would be good enough to free a little less than 700MB, but it’s not.

    Therefore I was hoping to use the option(IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX) but it only seems to work for readonly statements, not write :(

    Reply
  • Hi, I’ve disabled the index using ALTER INDEX myColumnStoreIndex ON myDWtable DISABLE but cannot update the table as I get the following error –

    Msg 8655, Level 16, State 1, Procedure sproc_Swift_Group_Registration_Member_Status_Update, Line 70 [Batch Start Line 98]
    The query processor is unable to produce a plan because the index ‘csIdx_Swift_Registration’ on table or view ‘Swift_Registration’ is disabled.

    Reply

Leave a Reply

Menu