EDIT (See Below for the Delete Query I Ran Manually): Thanks to ctlswadmin's prompting, I checked my nightly maintenance log (swdebugmaintenance.log) and sure enough, the maintenance was timing out each night when it came time to work on the AlertHistory table. I manually deleted all alerts older than 90 days from that table where their AlertActiveID was not in the AlertActive table and then manually ran a DB maintenance from the Orion server. All's good now. Thanks for all of the responses and help.
As confirmed by LadaVarga's response here, there is no way to set a retention period for the Alert History table. And I specifically mean the table in the Orion database called AlertHistory, not the Active Alerts table in the web console. We have a ton of alerts and our Alert History table is HUGE. I can query it and get results from as long ago as 12/24/2015, which is a lot more than the 60 days our "Event Retention" setting is set at. I bring up the Event Retention because in LadaVarga's reply I linked to she mentions that the AlertHistory table uses the Event Retention time, which doesn't seem to be true since our Events table only has the last 60 days worth of events whereas our AlertHistory table has 9 months of events. I also find that 9 months is a pretty odd number of days since I don't see any setting in our Polling Settings where we have 270 days set as the retention period...
I see a Stored Procedure in the Orion database called dbm_AlertHistory_DeleteStale, but what process within the Orion software uses this procedure and how can we decide the datetime value to feed into this? Because of the AlertHistory table's size, a lot of our Orion web console views that display historical alert information take a really long time to load. Our SWISv3 logs are fully of "Query Took a Long Time to Execute" warnings and nearly every one of those queries causing the warning are against the AlertHistory table.
Is it safe for me to copy/paste the SQL from this stored procedure and manually run it with the datetime variable defined to a value of my choosing? I'm thinking anything older than 90 days needs to go. What effect will this have on the Alert Details views since they give a lot of historical info about the alerts, like how many times a particular object has triggered this alert for example?
Here is what I ran manually to get my AlertHistory table to a smaller size so that the nightly maintenance could start taking over again and not timing out on this table. You can change the number of days to match what your Event Retention period is in your Polling Settings:
BEGIN SET NOCOUNT ON; DECLARE @EventHistoryRetention as int DECLARE @ChunkSize as int /* This number should be equal or greater than your Event Retention setting in Settings > Polling Settings */ SET @EventHistoryRetention = 90 /* How many records to delete at a time. I recommend leaving this at 1,000 */ SET @ChunkSize = 1000 SET IMPLICIT_TRANSACTIONS OFF SET ROWCOUNT @ChunkSize NextChunk: DELETE FROM /* You can comment out the "DELETE FROM" line above and uncomment the "SELECT * FROM" line below to see the first chunk that it would delete. Good for verifying before running. */ --SELECT * FROM AlertHistory Where [TimeStamp] < DATEADD(DAY,-@ROWCOUNT = @ChunkSize GOTO NextChunkEND