source: npl/mailserver/dspam/dspam-3.10.2/src/tools.mysql_drv/purge.sql @ c5c522c

gcc484ntopperl-5.22
Last change on this file since c5c522c was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 2.1 KB
Line 
1-- $Id: purge.sql,v 1.8 2009/12/19 17:50:03 sbajic Exp $
2
3-- ---------------------------------------------------------------------------
4--  ! ! ! ! ! ! ! THIS FILE SHOULD ONLY BE USED ON MYSQL < 4.1 ! ! ! ! ! ! !
5--  ! ! ! ! ! ! ! FOR MYSQL 4.1+ PLEASE USE purge-4.1.sql FILE ! ! ! ! ! ! !
6-- ---------------------------------------------------------------------------
7
8-- ---------------------------------------------------------------------------
9-- Note: Should you have modified your dspam.conf to have other intervals for
10--       the purging then please modify this SQL file to be in sync with your
11--       dspam.conf.
12--
13-- Note: It is difficult to purge neutral tokens with SQL clauses the same
14--       way as dspam_clean is doing it. So you should still run dspam_clean
15--       with the "-u" parameter from time to time.
16-- ---------------------------------------------------------------------------
17
18--
19-- Set some defaults
20--
21SET @PurgeSignatures = 14;          -- Stale signatures
22SET @PurgeUnused     = 90;          -- Unused tokens
23SET @PurgeHapaxes    = 30;          -- Tokens with less than 5 hits (hapaxes)
24SET @PurgeHits1S     = 15;          -- Tokens with only 1 spam hit
25SET @PurgeHits1I     = 15;          -- Tokens with only 1 innocent hit
26SET @today           = to_days(current_date());
27
28--
29-- Delete tokens with less than 5 hits (hapaxes)
30--
31DELETE
32  FROM dspam_token_data
33    WHERE from_days(@today-@PurgeHapaxes) > last_hit
34      AND (2*innocent_hits)+spam_hits < 5;
35
36--
37-- Delete tokens with only 1 spam hit
38--
39DELETE
40  FROM dspam_token_data
41    WHERE from_days(@today-@PurgeHits1S) > last_hit
42      AND innocent_hits = 0 AND spam_hits = 1;
43
44--
45-- Delete tokens with only 1 innocent hit
46--
47DELETE
48  FROM dspam_token_data
49    WHERE from_days(@today-@PurgeHits1I) > last_hit
50      AND innocent_hits = 1 AND spam_hits = 0;
51
52--
53-- Delete old tokens not seen for a while
54--
55DELETE
56  FROM dspam_token_data
57    WHERE from_days(@today-@PurgeUnused) > last_hit;
58
59--
60-- Delete stale signatures
61--
62DELETE
63  FROM dspam_signature_data
64    WHERE from_days(@today-@PurgeSignatures) > created_on;
Note: See TracBrowser for help on using the repository browser.