SQL Code Help |
Post Reply |
Author | |
jerbo128
Senior Member Joined: 06 March 2006 Status: Offline Points: 178 |
Post Options
Thanks(0)
Posted: 30 May 2007 at 5:39pm |
Can someone please suggest a bit of SQL code that will compare the tblMSGS and tblQuarantine and delete the orphaned entires. My quarantine table has 400K entries and my messages table has 750K. I'm not real handy with SQL queries, but can usually tweak pre-mades to fit my situation. Thanks for the help jerbo182 |
|
sgeorge
Senior Member Joined: 23 August 2005 Status: Offline Points: 178 |
Post Options
Thanks(0)
|
Hey man, happy to help. Since I tend to delete from the tlbQuarantine table instead of from tblMsgs, I too need to clean out the orphans from time to time. Here's how to delete orphaned records in the message table:
The following SQL code works in MS Access 2000 database.
To view the records before deleting them, replace "DELETE" with "select" in the query above Because of the way that this relational database is structured, it should not be possible for orphaned quarantine entries to exist. Hence, you don't have to worry about using a reciprocal query for deleting orphaned tblQuarantine records. When you delete a record from the tblMsgs table, any records in tblQuarantine that referenced that message record should be automatically deleted. I hope that helps, Stephen |
|
LogSat
Admin Group Joined: 25 January 2005 Location: United States Status: Offline Points: 4104 |
Post Options
Thanks(0)
|
Strange. The newer versions of SpamFilter (as of the last few months) should perform this orphan cleanup themselves...
While we look for potential problems, the query we use is (should work on all DB platforms): DELETE tblMsgs FROM tblMsgs LEFT JOIN tblQuarantine |
|
sgeorge
Senior Member Joined: 23 August 2005 Status: Offline Points: 178 |
Post Options
Thanks(0)
|
Well for my part, I'll clarify that my orphans are due to my specific database usage, and don't represent any problem with the software...
Here's what I do when I search and clean my database...
|
|
jerbo128
Senior Member Joined: 06 March 2006 Status: Offline Points: 178 |
Post Options
Thanks(0)
|
I have some users that refuse to check their quarantine except for once every week. They then accumulate so many messages, that my webserver times out when they try to delete 4000 messages at one time. I have come up with a bit of sql that will search the quarantine for users with more than 2000 messages. It is: SELECT emailto, COUNT(1) AS Number2 What I would like to do is this: Is anyone doing anything like this? Comments?... |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
This page was generated in 0.258 seconds.