Created
July 26, 2021 09:50
-
-
Save ghotz/617e4b8d1792c9828b51f66a79b920c7 to your computer and use it in GitHub Desktop.
Convert Perfmon clustered index based tables to clustered columnstore based tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @pkname sysname = (SELECT [name] FROM sys.key_constraints WHERE [type] = 'PK' AND parent_object_id = OBJECT_ID(N'dbo.CounterDetails')); | |
DECLARE @sqlstmt nvarchar(max) = N'ALTER TABLE dbo.CounterDetails DROP CONSTRAINT [' + @pkname + ']'; | |
EXEC (@sqlstmt); | |
CREATE CLUSTERED COLUMNSTORE INDEX cci_CounterDetails ON dbo.CounterDetails | |
WITH (DROP_EXISTING = OFF, COMPRESSION_DELAY = 0, MAXDOP = 1); | |
--ALTER TABLE dbo.CounterDetails | |
--ADD CONSTRAINT PK_CounterDetails PRIMARY KEY NONCLUSTERED (CounterID); | |
GO | |
DECLARE @pkname sysname = (SELECT [name] FROM sys.key_constraints WHERE [type] = 'PK' AND parent_object_id = OBJECT_ID(N'dbo.CounterData')); | |
DECLARE @sqlstmt nvarchar(max) = N'ALTER TABLE dbo.CounterData DROP CONSTRAINT [' + @pkname + ']'; | |
EXEC (@sqlstmt); | |
CREATE CLUSTERED COLUMNSTORE INDEX cci_CounterData ON dbo.CounterData | |
WITH (DROP_EXISTING = OFF, COMPRESSION_DELAY = 0, MAXDOP = 1); | |
--ALTER TABLE dbo.CounterData | |
--ADD CONSTRAINT PK_CounterData PRIMARY KEY NONCLUSTERED ([GUID], CounterID, RecordIndex); | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment