2013-05-28 Ramon Novoa <rnovoa@artica.es>
* util/pandora_db.pl: Use $BIG_OPERATION_STEP for event deletion. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8220 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
2b9aa32362
commit
15941bea61
|
@ -1,3 +1,7 @@
|
|||
2013-05-28 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* util/pandora_db.pl: Use $BIG_OPERATION_STEP for event deletion.
|
||||
|
||||
2013-05-27 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* util/pandora_db.pl: Several fixes. Save the last compact date
|
||||
|
|
|
@ -151,7 +151,6 @@ sub pandora_purgedb ($$) {
|
|||
print "[PURGE] Moving old not validated events to history table (More than " . $conf->{'_event_purge'} . " days)... \n";
|
||||
|
||||
my @events = get_db_rows ($dbh, 'SELECT * FROM tmetaconsole_event WHERE estado = 0 AND utimestamp < ?', $event_limit);
|
||||
|
||||
foreach my $event (@events) {
|
||||
db_process_insert($dbh, 'id_evento', 'tmetaconsole_event_history', $event);
|
||||
}
|
||||
|
@ -160,24 +159,22 @@ sub pandora_purgedb ($$) {
|
|||
$events_table = 'tmetaconsole_event';
|
||||
}
|
||||
|
||||
print "[PURGE] Deleting old event data at $events_table table (More than " . $conf->{'_event_purge'} . " days)... \n";
|
||||
print "[PURGE] Deleting old event data at $events_table table (More than " . $conf->{'_event_purge'} . " days)";
|
||||
|
||||
# Delete with buffer to avoid problems with performance
|
||||
my $buffer = 1000;
|
||||
|
||||
my $events_to_delete = get_db_value ($dbh, "SELECT COUNT(*) FROM $events_table WHERE utimestamp < ?", $event_limit);
|
||||
|
||||
while(1) {
|
||||
db_do($dbh, "DELETE FROM $events_table WHERE utimestamp < ? LIMIT ?", $event_limit, $buffer);
|
||||
db_do($dbh, "DELETE FROM $events_table WHERE utimestamp < ? LIMIT ?", $event_limit, $BIG_OPERATION_STEP);
|
||||
|
||||
if($events_to_delete <= $buffer) {
|
||||
if($events_to_delete <= $BIG_OPERATION_STEP) {
|
||||
last;
|
||||
}
|
||||
else {
|
||||
$events_to_delete = $events_to_delete - $buffer;
|
||||
$events_to_delete = $events_to_delete - $BIG_OPERATION_STEP;
|
||||
}
|
||||
print ".";
|
||||
}
|
||||
|
||||
print "\n";
|
||||
|
||||
# Delete audit data
|
||||
if (!defined($conf->{'_audit_purge'})){
|
||||
|
|
Loading…
Reference in New Issue