File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -74,3 +74,8 @@ SELECT COUNT(itemid) FROM history_text WHERE itemid NOT IN (SELECT itemid FROM i
74
74
75
75
SELECT COUNT (itemid) FROM trends WHERE itemid NOT IN (SELECT itemid FROM items);
76
76
SELECT COUNT (itemid) FROM trends_uint WHERE itemid NOT IN (SELECT itemid FROM items);
77
+
78
+ -- Count the amount of records in the events table for triggers/items that no longer exist
79
+ SELECT COUNT (eventid) FROM events WHERE source = 0 and object = 0 and objectid not in (select triggerid from triggers);
80
+ SELECT COUNT (eventid) FROM events WHERE source = 3 and object = 0 and objectid not in (select triggerid from triggers);
81
+ SELECT COUNT (eventid) FROM events WHERE source = 3 and object = 4 and objectid not in (select itemid from items);
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ DELETE FROM screens_items WHERE screenid NOT IN (SELECT screenid FROM screens);
65
65
DELETE FROM trigger_depends WHERE triggerid_down NOT IN (SELECT triggerid FROM triggers);
66
66
DELETE FROM trigger_depends WHERE triggerid_up NOT IN (SELECT triggerid FROM triggers);
67
67
68
- -- Count the amount of records in the history/trends table for items that no longer exist
68
+ -- Delete records in the history/trends table where items that no longer exist
69
69
DELETE FROM history WHERE itemid NOT IN (SELECT itemid FROM items);
70
70
DELETE FROM history_uint WHERE itemid NOT IN (SELECT itemid FROM items);
71
71
DELETE FROM history_log WHERE itemid NOT IN (SELECT itemid FROM items);
@@ -74,3 +74,8 @@ DELETE FROM history_text WHERE itemid NOT IN (SELECT itemid FROM items);
74
74
75
75
DELETE FROM trends WHERE itemid NOT IN (SELECT itemid FROM items);
76
76
DELETE FROM trends_uint WHERE itemid NOT IN (SELECT itemid FROM items);
77
+
78
+ -- Delete records in the events table where triggers/items that no longer exist
79
+ DELETE FROM events WHERE source = 0 and object = 0 and objectid not in (select triggerid from triggers);
80
+ DELETE FROM events WHERE source = 3 and object = 0 and objectid not in (select triggerid from triggers);
81
+ DELETE FROM events WHERE source = 3 and object = 4 and objectid not in (select itemid from items);
You can’t perform that action at this time.
0 commit comments