I recently noticed the database slowing down on the SQL server that is running the Quarantine. After some troubleshooting. I found the process that performs the following query causing blocking in the tables.
delete tblmsgs from tblmsgs left join tblquarantine on tblmsgs.msgid = tblquarantine.msgid where (tblquarantine.msgid is null);
This task would run for about 40 minutes, then stop, then about 15 minutes later it would run again with the same results.
I ran the following query which returned about 2.5 million results.
select count(*) from tblmsgs left join tblquarantine on tblmsgs.msgid = tblquarantine.msgid where (tblquarantine.msgid is null);
It appears this task is supposed to clean the database by deleting actual messages that do not have a corresponding tblquarantine entry. However, with 2.5 million messages in the table it appears that is has not been running properly.
So a few questions.
- What is actually kicking off this process. Is the SPAM server, or is it a SQL job somewhere
- Is there way to set it to not lock the tbmsgs table so that it does not block other tasks.
- Why would the task be running, but not actually deleting the messages. Is it possible that there are too many messages for it to handle and it is erroring out.
- Is there an issue with running the following statement so that I can accomplish what the job is trying to do manually in smaller increments of 25000.
select top 25000 tblmsgs.msgid FROM tblmsgs left join tblquarantine on tblmsgs.msgid = tblquarantine.msgid where (tblquarantine.msgid is null) and tblmsgs.msgid not in (select msgid from tblquarantine) order by tblmsgs.msgid
delete tblmsgs from tblmsgs left join tblquarantine on tblmsgs.msgid = tblquarantine.msgid where (tblquarantine.msgid is null) and tblmsgs.msgid < 30585604
|