Skip to content

Commit b899d49

Browse files
1.4.2 All Stored Procs Scripts Update
1 parent d0b11b1 commit b899d49

File tree

6 files changed

+273
-216
lines changed

6 files changed

+273
-216
lines changed

Azure/StoredProcs/cstore_install_all_stored_procs.sql

+36-53
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
CSIL - Columnstore Indexes Scripts Library for SQL Server 2016:
33
Columnstore Alignment - Shows the alignment (ordering) between the different Columnstore Segments
4-
Version: 1.4.1, November 2016
4+
Version: 1.4.2, December 2016
55
66
Copyright 2015-2016 Niko Neugebauer, OH22 IS (http://www.nikoport.com/columnstore/), (http://www.oh22.is/)
77
@@ -58,16 +58,12 @@ end
5858

5959

6060
--------------------------------------------------------------------------------------------------------------------
61-
IF NOT EXISTS (select * from sys.objects where type = 'p' and name = 'cstore_GetAlignment' and schema_id = SCHEMA_ID('dbo') )
62-
exec ('create procedure dbo.cstore_GetAlignment as select 1');
63-
GO
64-
6561
/*
6662
CSIL - Columnstore Indexes Scripts Library for SQL Server 2016:
6763
Columnstore Alignment - Shows the alignment (ordering) between the different Columnstore Segments
68-
Version: 1.4.1, November 2016
64+
Version: 1.4.2, December 2016
6965
*/
70-
alter procedure dbo.cstore_GetAlignment(
66+
CREATE OR ALTER PROCEDURE dbo.cstore_GetAlignment(
7167
-- Params --
7268
@schemaName nvarchar(256) = NULL, -- Allows to show data filtered down to the specified schema
7369
@tableName nvarchar(256) = NULL, -- Allows to show data filtered down to 1 particular table
@@ -235,7 +231,7 @@ GO
235231
/*
236232
Columnstore Indexes Scripts Library for Azure SQLDatabase:
237233
Dictionaries Analysis - Shows detailed information about the Columnstore Dictionaries
238-
Version: 1.4.1, November 2016
234+
Version: 1.4.2, December 2016
239235
240236
Copyright 2015-2016 Niko Neugebauer, OH22 IS (http://www.nikoport.com/columnstore/), (http://www.oh22.is/)
241237
@@ -301,16 +297,12 @@ begin
301297
end
302298

303299
--------------------------------------------------------------------------------------------------------------------
304-
if NOT EXISTS (select * from sys.objects where type = 'p' and name = 'cstore_GetDictionaries' and schema_id = SCHEMA_ID('dbo') )
305-
exec ('create procedure dbo.cstore_GetDictionaries as select 1');
306-
GO
307-
308300
/*
309301
Columnstore Indexes Scripts Library for Azure SQLDatabase:
310302
Dictionaries Analysis - Shows detailed information about the Columnstore Dictionaries
311-
Version: 1.4.1, November 2016
303+
Version: 1.4.2, December 2016
312304
*/
313-
alter procedure dbo.cstore_GetDictionaries(
305+
CREATE OR ALTER PROCEDURE dbo.cstore_GetDictionaries(
314306
-- Params --
315307
@showDetails bit = 1, -- Enables showing the details of all Dictionaries
316308
@showWarningsOnly bit = 0, -- Enables to filter out the dictionaries based on the Dictionary Size (@warningDictionarySizeInMB) and Entry Count (@warningEntryCount)
@@ -497,7 +489,7 @@ GO
497489
/*
498490
Columnstore Indexes Scripts Library for Azure SQLDatabase:
499491
Columnstore Fragmenttion - Shows the different types of Columnstore Indexes Fragmentation
500-
Version: 1.4.1, November 2016
492+
Version: 1.4.2, December 2016
501493
502494
Copyright 2015-2016 Niko Neugebauer, OH22 IS (http://www.nikoport.com/columnstore/), (http://www.oh22.is/)
503495
@@ -558,17 +550,12 @@ begin
558550
end
559551

560552
--------------------------------------------------------------------------------------------------------------------
561-
562-
if NOT EXISTS (select * from sys.objects where type = 'p' and name = 'cstore_GetFragmentation' and schema_id = SCHEMA_ID('dbo') )
563-
exec ('create procedure dbo.cstore_GetFragmentation as select 1');
564-
GO
565-
566553
/*
567554
Columnstore Indexes Scripts Library for Azure SQLDatabase:
568555
Columnstore Fragmenttion - Shows the different types of Columnstore Indexes Fragmentation
569-
Version: 1.4.1, November 2016
556+
Version: 1.4.2, December 2016
570557
*/
571-
alter procedure dbo.cstore_GetFragmentation (
558+
CREATE OR ALTER PROCEDURE dbo.cstore_GetFragmentation (
572559
-- Params --
573560
@tableName nvarchar(256) = NULL, -- Allows to show data filtered down to 1 particular table
574561
@schemaName nvarchar(256) = NULL, -- Allows to show data filtered down to the specified schema
@@ -646,7 +633,7 @@ GO
646633
/*
647634
Columnstore Indexes Scripts Library for Azure SQLDatabase:
648635
Row Groups - Shows detailed information on the Columnstore Row Groups inside current Database
649-
Version: 1.4.1, November 2016
636+
Version: 1.4.2, December 2016
650637
651638
Copyright 2015-2016 Niko Neugebauer, OH22 IS (http://www.nikoport.com/columnstore/), (http://www.oh22.is/)
652639
@@ -690,6 +677,9 @@ Changes in 1.3.0
690677
Changes in 1.4.0
691678
- Added support for the Indexed Views with Nonclustered Columnstore Indexes
692679
- Added new parameter for filtering the Columnstore Object Type with possible values 'Table' & 'Indexed View'
680+
681+
Changes in 1.4.2
682+
- Fixed bug on lookup for the Object Name for the empty Columnstore tables
693683
*/
694684

695685
declare @SQLServerVersion nvarchar(128) = cast(SERVERPROPERTY('ProductVersion') as NVARCHAR(128)),
@@ -704,16 +694,12 @@ begin
704694
end
705695

706696
--------------------------------------------------------------------------------------------------------------------
707-
if NOT EXISTS (select * from sys.objects where type = 'p' and name = 'cstore_GetRowGroups' and schema_id = SCHEMA_ID('dbo') )
708-
exec ('create procedure dbo.cstore_GetRowGroups as select 1');
709-
GO
710-
711697
/*
712698
Columnstore Indexes Scripts Library for Azure SQLDatabase:
713699
Row Groups - Shows detailed information on the Columnstore Row Groups inside current Database
714-
Version: 1.4.1, November 2016
700+
Version: 1.4.2, December 2016
715701
*/
716-
alter procedure dbo.cstore_GetRowGroups(
702+
CREATE OR ALTER PROCEDURE dbo.cstore_GetRowGroups(
717703
-- Params --
718704
@indexType char(2) = NULL, -- Allows to filter Columnstore Indexes by their type, with possible values (CC for 'Clustered', NC for 'Nonclustered' or NULL for both)
719705
@objectType varchar(20) = NULL, -- Allows to filter the object type with 2 possible supported values: 'Table' & 'Indexed View'
@@ -743,7 +729,7 @@ begin
743729
sum(case state when 2 then 1 else 0 end) as 'Closed DS',
744730
sum(case state when 4 then 1 else 0 end) as 'Tombstones',
745731
sum(case state when 3 then 1 else 0 end) as 'Compressed',
746-
count(*) as 'Total',
732+
count(rg.object_id) as 'Total',
747733
cast( (sum(isnull(case state when 4 then 0 else deleted_rows end,0)) +
748734
(select isnull(sum(intpart.rows),0)
749735
from sys.internal_partitions intpart
@@ -779,8 +765,8 @@ begin
779765
and ind.data_space_id = isnull( case @indexLocation when 'In-Memory' then 0 when 'Disk-Based' then 1 else ind.data_space_id end, ind.data_space_id )
780766
and case @indexType when 'CC' then 5 when 'NC' then 6 else ind.type end = ind.type
781767
and case @compressionType when 'Columnstore' then 3 when 'Archive' then 4 else part.data_compression end = part.data_compression
782-
and (@tableName is null or object_name (rg.object_id) like '%' + @tableName + '%')
783-
and (@schemaName is null or object_schema_name(rg.object_id) = @schemaName)
768+
and (@tableName is null or object_name (ind.object_id) like '%' + @tableName + '%')
769+
and (@schemaName is null or object_schema_name(ind.object_id) = @schemaName)
784770
and obj.type_desc = ISNULL(case @objectType when 'Table' then 'USER_TABLE' when 'Indexed View' then 'VIEW' end,obj.type_desc)
785771
group by ind.object_id, ind.type, obj.type_desc, rg.partition_number, ind.data_space_id,
786772
part.partition_number
@@ -803,7 +789,7 @@ begin
803789
sum(case state when 2 then 1 else 0 end) as 'Closed DS',
804790
sum(case state when 4 then 1 else 0 end) as 'Tombstones',
805791
sum(case state when 3 then 1 else 0 end) as 'Compressed',
806-
count(*) as 'Total',
792+
count(rg.object_id) as 'Total',
807793
cast( (sum(isnull(case state when 4 then 0 else deleted_rows end,0)) +
808794
(select isnull(sum(intpart.rows),0)
809795
from tempdb.sys.internal_partitions intpart
@@ -839,7 +825,7 @@ begin
839825
and case @indexType when 'CC' then 5 when 'NC' then 6 else ind.type end = ind.type
840826
and ind.data_space_id = isnull( case @indexLocation when 'In-Memory' then 0 when 'Disk-Based' then 1 else ind.data_space_id end, ind.data_space_id )
841827
and case @compressionType when 'Columnstore' then 3 when 'Archive' then 4 else part.data_compression end = part.data_compression
842-
and (@tableName is null or obj.name like '%' + @tableName + '%')
828+
and (@tableName is null or ind.name like '%' + @tableName + '%')
843829
and (@schemaName is null or object_schema_name(ind.object_id, db_id('tempdb')) = @schemaName)
844830
-- and isnull(stat.database_id,db_id('tempdb')) = db_id('tempdb')
845831
and obj.type_desc = ISNULL(case @objectType when 'Table' then 'USER_TABLE' when 'Indexed View' then 'VIEW' end,obj.type_desc)
@@ -873,7 +859,7 @@ GO
873859
/*
874860
Columnstore Indexes Scripts Library for Azure SQLDatabase:
875861
Row Groups Details - Shows detailed information on the Columnstore Row Groups
876-
Version: 1.4.1, November 2016
862+
Version: 1.4.2, December 2016
877863
878864
Copyright 2015-2016 Niko Neugebauer, OH22 IS (http://www.nikoport.com/columnstore/), (http://www.oh22.is/)
879865
@@ -928,9 +914,9 @@ GO
928914
/*
929915
Columnstore Indexes Scripts Library for Azure SQLDatabase:
930916
Row Groups Details - Shows detailed information on the Columnstore Row Groups
931-
Version: 1.4.1, November 2016
917+
Version: 1.4.2, December 2016
932918
*/
933-
alter procedure dbo.cstore_GetRowGroupsDetails(
919+
CREATE OR ALTER PROCEDURE dbo.cstore_GetRowGroupsDetails(
934920
-- Params --
935921
@objectId int = NULL, -- Allows to idenitfy a table thorugh the ObjectId
936922
@schemaName nvarchar(256) = NULL, -- Allows to show data filtered down to the specified schema
@@ -1035,7 +1021,7 @@ GO
10351021
/*
10361022
Columnstore Indexes Scripts Library for Azure SQL Database:
10371023
Suggested Tables - Lists tables which potentially can be interesting for implementing Columnstore Indexes
1038-
Version: 1.4.1, November 2016
1024+
Version: 1.4.2, December 2016
10391025
10401026
Copyright 2015-2016 Niko Neugebauer, OH22 IS (http://www.nikoport.com/columnstore/), (http://www.oh22.is/)
10411027
@@ -1085,6 +1071,10 @@ Changes in 1.3.1
10851071
10861072
Changes in 1.4.1
10871073
+ Suggestion capability improvements
1074+
1075+
Changes in 1.4.2
1076+
- Fixed bug on the size of the @minSizeToConsiderInGB parameter
1077+
+ Small Improvements for the @columnstoreIndexTypeForTSQL parameter with better quality generation for the complex objects with Primary Keys
10881078
*/
10891079

10901080
declare @SQLServerVersion nvarchar(128) = cast(SERVERPROPERTY('ProductVersion') as NVARCHAR(128)),
@@ -1099,16 +1089,12 @@ begin
10991089
end
11001090

11011091
--------------------------------------------------------------------------------------------------------------------
1102-
if NOT EXISTS (select * from sys.objects where type = 'p' and name = 'cstore_SuggestedTables' and schema_id = SCHEMA_ID('dbo') )
1103-
exec ('create procedure dbo.cstore_SuggestedTables as select 1');
1104-
GO
1105-
11061092
/*
11071093
Columnstore Indexes Scripts Library for Azure SQL Database:
11081094
Suggested Tables - Lists tables which potentially can be interesting for implementing Columnstore Indexes
1109-
Version: 1.4.1, November 2016
1095+
Version: 1.4.2, December 2016
11101096
*/
1111-
alter procedure dbo.cstore_SuggestedTables(
1097+
CREATE OR ALTER PROCEDURE dbo.cstore_SuggestedTables(
11121098
-- Params --
11131099
@minRowsToConsider bigint = 500000, -- Minimum number of rows for a table to be considered for the suggestion inclusion
11141100
@minSizeToConsiderInGB Decimal(16,3) = 0.00, -- Minimum size in GB for a table to be considered for the suggestion inclusion
@@ -1289,7 +1275,7 @@ begin
12891275
OR
12901276
@considerColumnsOver8K = 1 )
12911277
and
1292-
(sum(a.total_pages) + isnull(sum(memory_allocated_for_table_kb),0) / 1024. / 1024 * 8.0 / 1024. / 1024 >= @minSizeToConsiderInGB)
1278+
(isnull(cast( sum(memory_allocated_for_table_kb) / 1024. / 1024 as decimal(16,3) ),0) + cast( sum(a.total_pages) * 8.0 / 1024. / 1024 as decimal(16,3)) >= @minSizeToConsiderInGB)
12931279
union all
12941280
select t.object_id as [ObjectId]
12951281
, 'Disk-Based'
@@ -1410,7 +1396,8 @@ begin
14101396
OR
14111397
@considerColumnsOver8K = 1 )
14121398
and
1413-
(sum(a.total_pages) * 8.0 / 1024. / 1024 >= @minSizeToConsiderInGB);
1399+
(cast( sum(a.total_pages) * 8.0 / 1024. / 1024 as decimal(16,3)) >= @minSizeToConsiderInGB);
1400+
14141401

14151402
-- Show the found results
14161403
select case when ([Triggers] + [FileStream] + [FileTable] + [Unsupported] - ([LOBs] + [Computed])) > 0 then 'None'
@@ -1554,7 +1541,7 @@ end
15541541
/*
15551542
CSIL - Columnstore Indexes Scripts Library for Azure SQLDatabase:
15561543
Columnstore Maintenance - Maintenance Solution for SQL Server Columnstore Indexes
1557-
Version: 1.4.1, November 2016
1544+
Version: 1.4.2, December 2016
15581545
15591546
Copyright 2015-2016 Niko Neugebauer, OH22 IS (http://www.nikoport.com/columnstore/), (http://www.oh22.is/)
15601547
@@ -1732,16 +1719,12 @@ end
17321719
GO
17331720

17341721
-- **************************************************************************************************************************
1735-
IF NOT EXISTS (select * from sys.objects where type = 'p' and name = 'cstore_doMaintenance' and schema_id = SCHEMA_ID('dbo') )
1736-
exec ('create procedure dbo.cstore_doMaintenance as select 1');
1737-
GO
1738-
17391722
/*
17401723
CSIL - Columnstore Indexes Scripts Library for Azure SQLDatabase:
17411724
Columnstore Maintenance - Maintenance Solution for SQL Server Columnstore Indexes
1742-
Version: 1.4.1, November 2016
1725+
Version: 1.4.2, December 2016
17431726
*/
1744-
alter procedure [dbo].[cstore_doMaintenance](
1727+
CREATE OR ALTER PROCEDURE [dbo].[cstore_doMaintenance](
17451728
-- Params --
17461729
@execute bit = 0, -- Controls if the maintenace is executed or not
17471730
@orderSegments bit = 0, -- Controls whether Segment Clustering is being applied or not

0 commit comments

Comments
 (0)