Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best possible ways to disable index before insert operation and enable back Index after insert

I'm planning to create a Non-clustered columnstore index on SQL Server 2014.

But non clustered column store index is read-only and cannot perform DML operations, we need to disable before insert and enable back after insert.

What are the best possible ways to perform this task?

like image 797
Jay Nani Avatar asked Nov 11 '16 17:11

Jay Nani


People also ask

How do I disable and enable indexes in SQL Server?

To enable a disabled index Click the plus sign to expand the Indexes folder. Right-click the index you want to enable and select Rebuild. In the Rebuild Indexes dialog box, verify that the correct index is in the Indexes to rebuild grid and click OK.

How do I enable and disable indexes in Oracle?

To disable an index, you run an ALTER INDEX command: ALTER INDEX index_name ON table_name DISABLE; You can replace the index_name with the name of your index, and the table_name with the name of the table that the index is created on.


1 Answers

Simply disable the index and perform a rebuild. https://msdn.microsoft.com/en-us/library/dn589806(v=sql.120).aspx

ALTER INDEX mycolumnstoreindex ON mytable DISABLE;  
-- update mytable --  
ALTER INDEX mycolumnstoreindex on mytable REBUILD  
like image 166
Derrick Moeller Avatar answered Oct 19 '22 19:10

Derrick Moeller