Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagesql
DECLARE @DeleteBefore DATETIME = CAST('2000-12-31T00:00:00' AS DATETIME)

DELETE FROM Contexts WHERE ContextType = 'ElementContext' AND FlowContextId IN (SELECT Id FROM Contexts WHERE FlowContextIdContextType IS= NULL'FlowContext' AND CreateTime < @DeleteBefore);
DELETE FROM ContextIndices WHERE FlowContextId IN (SELECT Id FROM Contexts WHERE FlowContextIdContextType IS= NULL'FlowContext' AND CreateTime < @DeleteBefore);
DELETE FROM ContextLogs WHERE FlowContextId IN (SELECT Id FROM Contexts WHERE FlowContextIdContextType IS= NULL'FlowContext' AND CreateTime < @DeleteBefore);
DELETE FROM Contexts WHERE FlowContextIdContextType IS= NULL'FlowContext' 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')

...