...
Code Block |
---|
|
DECLARE @DeleteBefore DATETIME = CAST('2000-12-31T00:00:00' AS DATETIME)
DELETE FROM Contexts WHERE FlowContextId IN (SELECT Id FROM Contexts WHERE FlowContextId IS NULL AND CreateTime < @DeleteBefore);
DELETE FROM ContextIndices WHERE FlowContextId IN (SELECT Id FROM Contexts WHERE FlowContextId IS NULL AND CreateTime < @DeleteBefore);
DELETE FROM ContextLogs WHERE FlowContextId IN (SELECT Id FROM Contexts WHERE FlowContextId IS NULL AND CreateTime < @DeleteBefore);
DELETE FROM Contexts WHERE FlowContextId IS NULL AND CreateTime < @DeleteBefore;
DELETE FROM PerformanceRecords WHERE [Time] < @DeleteBefore;
DBCC INDEXDEFRAG(0, 'Contexts')
DBCC INDEXDEFRAG(0, 'ContextIndices')
DBCC INDEXDEFRAG(0, 'ContextLogs')
DBCC INDEXDEFRAG(0, 'PerformanceRecords') |
Sollen alle Kontexte und Leistungsdatensätze gelöschte werden, kann dieser Vorgang durch die Verwendung von TRUNCATE beschleunigt werden:
Code Block |
---|
|
TRUNCATE TABLE Contexts;
TRUNCATE TABLE ContextLogs;
TRUNCATE TABLE ContextIndices;
TRUNCATE TABLE PerformanceRecords;
DBCC INDEXDEFRAG(0, 'Contexts')
DBCC INDEXDEFRAG(0, 'ContextIndices')
DBCC INDEXDEFRAG(0, 'ContextLogs')
DBCC INDEXDEFRAG(0, 'PerformanceRecords') |
Verkleinern der Datenbank
...