-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove legacy BlockingSnapshot table. Don't need to handle deletes for this table - should be removed instead. Add SPs to remove data for a specific instance from various tables. Can also be used to reduce retention for a specific instance (Not efficient compared to partition switching though) Add data cleanup for BlockingSnapshotSummary table based on retention settings for RunningQueries. Add indexes to help support delete operation Remove certain FKs to avoid the need for a supporting index. #119 Update Docs
- Loading branch information
1 parent
ec713c7
commit 6591811
Showing
49 changed files
with
1,269 additions
and
370 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
28 changes: 0 additions & 28 deletions
28
DBADashDB/dbo/Functions/BlockingSnapshotRecursiveStats.sql
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
DBADashDB/dbo/Stored Procedures/AzureDBElasticPoolResourceStats_60MIN_Del.sql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
CREATE PROC dbo.AzureDBElasticPoolResourceStats_60MIN_Del( | ||
@InstanceID INT, | ||
@DaysToKeep INT, | ||
@BatchSize INT = 500000 | ||
) | ||
AS | ||
/* | ||
Partitioning switching is used to efficiently remove data from this table for all instances. | ||
This proc provides an alternative way to remove data associated with a specific instance. | ||
*/ | ||
SET NOCOUNT ON | ||
DECLARE @MaxDate DATETIME2 | ||
SELECT @MaxDate = CASE WHEN @DaysToKeep = 0 THEN '30000101' ELSE DATEADD(d,-@DaysToKeep,GETUTCDATE()) END | ||
|
||
WHILE 1=1 | ||
BEGIN | ||
DELETE EPRS | ||
FROM dbo.AzureDBElasticPoolResourceStats_60MIN EPRS | ||
WHERE EXISTS(SELECT 1 | ||
FROM dbo.AzureDBElasticPool EP | ||
WHERE EP.InstanceID = @InstanceID | ||
AND EP.PoolID = EPRS.PoolID | ||
) | ||
AND end_time < @MaxDate | ||
OPTION(RECOMPILE) | ||
|
||
IF @@ROWCOUNT < @BatchSize | ||
BREAK | ||
END |
29 changes: 29 additions & 0 deletions
29
DBADashDB/dbo/Stored Procedures/AzureDBElasticPoolResourceStats_Del.sql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
CREATE PROC dbo.AzureDBElasticPoolResourceStats_Del( | ||
@InstanceID INT, | ||
@DaysToKeep INT, | ||
@BatchSize INT = 500000 | ||
) | ||
AS | ||
/* | ||
Partitioning switching is used to efficiently remove data from this table for all instances. | ||
This proc provides an alternative way to remove data associated with a specific instance. | ||
*/ | ||
SET NOCOUNT ON | ||
DECLARE @MaxDate DATETIME2 | ||
SELECT @MaxDate = CASE WHEN @DaysToKeep = 0 THEN '30000101' ELSE DATEADD(d,-@DaysToKeep,GETUTCDATE()) END | ||
|
||
WHILE 1=1 | ||
BEGIN | ||
DELETE EPRS | ||
FROM dbo.AzureDBElasticPoolResourceStats EPRS | ||
WHERE EXISTS(SELECT 1 | ||
FROM dbo.AzureDBElasticPool EP | ||
WHERE EP.InstanceID = @InstanceID | ||
AND EP.PoolID = EPRS.PoolID | ||
) | ||
AND end_time < @MaxDate | ||
OPTION(RECOMPILE) | ||
|
||
IF @@ROWCOUNT < @BatchSize | ||
BREAK | ||
END |
25 changes: 25 additions & 0 deletions
25
DBADashDB/dbo/Stored Procedures/AzureDBResourceStats_60MIN_Del.sql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
CREATE PROC dbo.AzureDBResourceStats_60MIN_Del( | ||
@InstanceID INT, | ||
@DaysToKeep INT, | ||
@BatchSize INT=500000 | ||
) | ||
AS | ||
/* | ||
Partitioning switching is used to efficiently remove data from this table for all instances. | ||
This proc provides an alternative way to remove data associated with a specific instance. | ||
*/ | ||
SET NOCOUNT ON | ||
DECLARE @MaxDate DATETIME2(3) | ||
SELECT @MaxDate = CASE WHEN @DaysToKeep = 0 THEN '30000101' ELSE DATEADD(d,-@DaysToKeep,GETUTCDATE()) END | ||
|
||
WHILE 1=1 | ||
BEGIN | ||
DELETE TOP(@BatchSize) EPRS | ||
FROM dbo.AzureDBResourceStats_60MIN EPRS | ||
WHERE InstanceID = @InstanceID | ||
AND end_time < @MaxDate | ||
OPTION(RECOMPILE) | ||
|
||
IF @@ROWCOUNT < @BatchSize | ||
BREAK | ||
END |
25 changes: 25 additions & 0 deletions
25
DBADashDB/dbo/Stored Procedures/AzureDBResourceStats_Del.sql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
CREATE PROC dbo.AzureDBResourceStats_Del( | ||
@InstanceID INT, | ||
@DaysToKeep INT, | ||
@BatchSize INT=500000 | ||
) | ||
AS | ||
/* | ||
Partitioning switching is used to efficiently remove data from this table for all instances. | ||
This proc provides an alternative way to remove data associated with a specific instance. | ||
*/ | ||
SET NOCOUNT ON | ||
DECLARE @MaxDate DATETIME2(3) | ||
SELECT @MaxDate = CASE WHEN @DaysToKeep = 0 THEN '30000101' ELSE DATEADD(d,-@DaysToKeep,GETUTCDATE()) END | ||
|
||
WHILE 1=1 | ||
BEGIN | ||
DELETE TOP(@BatchSize) EPRS | ||
FROM dbo.AzureDBResourceStats EPRS | ||
WHERE InstanceID = @InstanceID | ||
AND end_time < @MaxDate | ||
OPTION(RECOMPILE) | ||
|
||
IF @@ROWCOUNT < @BatchSize | ||
BREAK | ||
END |
28 changes: 28 additions & 0 deletions
28
DBADashDB/dbo/Stored Procedures/BlockingSnapshotSummary_Del.sql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
CREATE PROC dbo.BlockingSnapshotSummary_Del( | ||
@InstanceID INT, | ||
@DaysToKeep INT, | ||
@BatchSize INT = 500000 | ||
) | ||
AS | ||
/* | ||
Partitioning switching is used to efficiently remove data from this table for all instances. | ||
This proc provides an alternative way to remove data associated with a specific instance. | ||
*/ | ||
SET NOCOUNT ON | ||
DECLARE @MaxDate DATETIME2 | ||
SELECT @MaxDate = CASE WHEN @DaysToKeep = 0 THEN '30000101' ELSE DATEADD(d,-@DaysToKeep,GETUTCDATE()) END | ||
|
||
SELECT @MaxDate = DATEADD(d,-RetentionDays,GETUTCDATE()) | ||
FROM dbo.DataRetention | ||
WHERE TableName = 'RunningQueries' | ||
|
||
WHILE 1=1 | ||
BEGIN | ||
DELETE TOP(@BatchSize) | ||
FROM dbo.BlockingSnapshotSummary | ||
WHERE SnapshotDateUTC < @MaxDate | ||
AND InstanceID = @InstanceID | ||
|
||
IF @@ROWCOUNT<@BatchSize | ||
BREAK | ||
END |
Oops, something went wrong.