Solution
LDD: To reduce the data size of TASK LOG and TASK_INFO tables in MONITOR database, the following query needs to be run:
- USE MONITOR;
- DECLARE @baseDate DATE= '2019-01-01'
- SELECT COUNT(*) FROM TASK_LOG; ----total number of records in TASK_LOG before deleting records
- DELETE FROM TASK_LOG WHERE TASK_ID IN (SELECT TASK_ID FROM TASK_INFO WHERE START_TIME < @baseDate);
- SELECT COUNT(*) FROM TASK_LOG; --total number of records in TASK_LOG after deleting records
- SELECT COUNT(*) FROM TASK_INFO; ----total number of records in TASK_INFO before deleting records
- DELETE FROM TASK_INFO WHERE START_TIME < @baseDate;
- SELECT COUNT(*) FROM TASK_INFO; ---total number of records in TASK_INFO after deleting records
LPM: To reduce the data size of PR_STATS and PR_STATS_PAGES tables in PrintRelease DB, it is recommended to delete old records. To do this, the following query can be run:
- USE PRINTRELEASE;
- DECLARE @baseDate DATE = '2019-01-01'
- SELECT COUNT(*) FROM PR_STATS_PAGES; --total number of records in PR_STATS_PAGES before deleting old records
- DELETE FROM PR_STATS_PAGES WHERE JOBID IN (SELECT ID FROM PR_STATS WHERE FINALDATE < @baseDate);
- SELECT COUNT(*) FROM PR_STATS_PAGES; --total number of records in PR_STATS_PAGES after deleting old records
- SELECT COUNT(*) FROM PR_STATS; --total number of records in PR_STATS before deleting old records
- DELETE FROM PR_STATS WHERE FINALDATE < @baseDate;
- SELECT COUNT(*) FROM PR_STATS; --total number of records in PR_STATS after deleting old records