Added --no-optimize-tables flag to cold-storage script
git-svn-id: svn://192.168.202.10@3851 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -20,13 +20,15 @@
|
||||
#
|
||||
# CHANGES
|
||||
# 240704-1815 - First version
|
||||
# 250705-0954 - Added --query-count-test flag option
|
||||
# 240705-0954 - Added --query-count-test flag option
|
||||
# 240711-1938 - Added --no-optimize-tables flag option
|
||||
#
|
||||
|
||||
$DB=0;
|
||||
$DBX=0;
|
||||
$CALC_TEST=0;
|
||||
$QUERY_COUNT_TEST=0;
|
||||
$NO_OPTIMIZE_TABLES=0;
|
||||
$T=0; $TEST=0;
|
||||
$only_trim_archive=0;
|
||||
$recording_log_archive=0;
|
||||
@@ -55,6 +57,7 @@ if (length($ARGV[0])>1)
|
||||
print " [--quiet] = quiet\n";
|
||||
print " [--calc-test] = date calculation test only\n";
|
||||
print " [--query-count-test] = run archive counts test only\n";
|
||||
print " [--no-optimize-tables] = do not optimize the archive tables after deletion of rows \n";
|
||||
print " [--test] = test\n";
|
||||
print " [--debug] = debug output for some options\n";
|
||||
print " [--debugX] = extra debug output for some options\n";
|
||||
@@ -92,6 +95,11 @@ if (length($ARGV[0])>1)
|
||||
$QUERY_COUNT_TEST=1;
|
||||
print "\n-----ARCHIVE TABLES QUERY COUNT TESTING ONLY: $QUERY_COUNT_TEST-----\n\n";
|
||||
}
|
||||
if ($args =~ /--no-optimize-tables/i)
|
||||
{
|
||||
$NO_OPTIMIZE_TABLES=1;
|
||||
print "\n-----DO NOT OPTIMIZE ARCHIVE TABLES AFTER ROWS DELETION: $NO_OPTIMIZE_TABLES-----\n\n";
|
||||
}
|
||||
if ($args =~ /--days=/i)
|
||||
{
|
||||
@data_in = split(/--days=/,$args);
|
||||
@@ -391,11 +399,18 @@ if (!$T)
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if (!$Q) {print STDERR "records deleted from call_log_archive: $affected_rowsA|$stmtA|\n";}
|
||||
|
||||
if ($NO_OPTIMIZE_TABLES < 1)
|
||||
{
|
||||
$stmtA = "OPTIMIZE TABLE call_log_archive;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
if (!$Q) {print STDERR "call_log_archive table optimized, cold-storage process is complete for this table!\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$Q) {print STDERR "call_log_archive table skip optimize\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
##### END call_log_archive cold-storage processing #####
|
||||
@@ -546,11 +561,18 @@ if (!$T)
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if (!$Q) {print STDERR "records deleted from vicidial_log_archive: $affected_rowsA|$stmtA|\n";}
|
||||
|
||||
if ($NO_OPTIMIZE_TABLES < 1)
|
||||
{
|
||||
$stmtA = "OPTIMIZE TABLE vicidial_log_archive;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
if (!$Q) {print STDERR "vicidial_log_archive table optimized, cold-storage process is complete for this table!\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$Q) {print STDERR "vicidial_log_archive table skip optimize\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
##### END vicidial_log_archive cold-storage processing #####
|
||||
@@ -701,11 +723,18 @@ if (!$T)
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if (!$Q) {print STDERR "records deleted from vicidial_log_extended_archive: $affected_rowsA|$stmtA|\n";}
|
||||
|
||||
if ($NO_OPTIMIZE_TABLES < 1)
|
||||
{
|
||||
$stmtA = "OPTIMIZE TABLE vicidial_log_extended_archive;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
if (!$Q) {print STDERR "vicidial_log_extended_archive table optimized, cold-storage process is complete for this table!\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$Q) {print STDERR "vicidial_log_extended_archive table skip optimize\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
##### END vicidial_log_extended_archive cold-storage processing #####
|
||||
@@ -856,11 +885,18 @@ if (!$T)
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if (!$Q) {print STDERR "records deleted from vicidial_dial_log_archive: $affected_rowsA|$stmtA|\n";}
|
||||
|
||||
if ($NO_OPTIMIZE_TABLES < 1)
|
||||
{
|
||||
$stmtA = "OPTIMIZE TABLE vicidial_dial_log_archive;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
if (!$Q) {print STDERR "vicidial_dial_log_archive table optimized, cold-storage process is complete for this table!\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$Q) {print STDERR "vicidial_dial_log_archive table skip optimize\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
##### END vicidial_dial_log_archive cold-storage processing #####
|
||||
@@ -1011,11 +1047,18 @@ if (!$T)
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if (!$Q) {print STDERR "records deleted from vicidial_carrier_log_archive: $affected_rowsA|$stmtA|\n";}
|
||||
|
||||
if ($NO_OPTIMIZE_TABLES < 1)
|
||||
{
|
||||
$stmtA = "OPTIMIZE TABLE vicidial_carrier_log_archive;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
if (!$Q) {print STDERR "vicidial_carrier_log_archive table optimized, cold-storage process is complete for this table!\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$Q) {print STDERR "vicidial_carrier_log_archive table skip optimize\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
##### END vicidial_carrier_log_archive cold-storage processing #####
|
||||
@@ -1166,11 +1209,18 @@ if (!$T)
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if (!$Q) {print STDERR "records deleted from vicidial_dial_cid_log_archive: $affected_rowsA|$stmtA|\n";}
|
||||
|
||||
if ($NO_OPTIMIZE_TABLES < 1)
|
||||
{
|
||||
$stmtA = "OPTIMIZE TABLE vicidial_dial_cid_log_archive;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
if (!$Q) {print STDERR "vicidial_dial_cid_log_archive table optimized, cold-storage process is complete for this table!\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$Q) {print STDERR "vicidial_dial_cid_log_archive table skip optimize\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
##### END vicidial_dial_cid_log_archive cold-storage processing #####
|
||||
@@ -1321,11 +1371,18 @@ if (!$T)
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if (!$Q) {print STDERR "records deleted from vicidial_amd_log_archive: $affected_rowsA|$stmtA|\n";}
|
||||
|
||||
if ($NO_OPTIMIZE_TABLES < 1)
|
||||
{
|
||||
$stmtA = "OPTIMIZE TABLE vicidial_amd_log_archive;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
if (!$Q) {print STDERR "vicidial_amd_log_archive table optimized, cold-storage process is complete for this table!\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$Q) {print STDERR "vicidial_amd_log_archive table skip optimize\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
##### END vicidial_amd_log_archive cold-storage processing #####
|
||||
@@ -1476,11 +1533,18 @@ if (!$T)
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if (!$Q) {print STDERR "records deleted from vicidial_agent_log_archive: $affected_rowsA|$stmtA|\n";}
|
||||
|
||||
if ($NO_OPTIMIZE_TABLES < 1)
|
||||
{
|
||||
$stmtA = "OPTIMIZE TABLE vicidial_agent_log_archive;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
if (!$Q) {print STDERR "vicidial_agent_log_archive table optimized, cold-storage process is complete for this table!\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$Q) {print STDERR "vicidial_agent_log_archive table skip optimize\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
##### END vicidial_agent_log_archive cold-storage processing #####
|
||||
@@ -1631,11 +1695,18 @@ if (!$T)
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if (!$Q) {print STDERR "records deleted from vicidial_api_log_archive: $affected_rowsA|$stmtA|\n";}
|
||||
|
||||
if ($NO_OPTIMIZE_TABLES < 1)
|
||||
{
|
||||
$stmtA = "OPTIMIZE TABLE vicidial_api_log_archive;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
if (!$Q) {print STDERR "vicidial_api_log_archive table optimized, cold-storage process is complete for this table!\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$Q) {print STDERR "vicidial_api_log_archive table skip optimize\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
##### END vicidial_api_log_archive cold-storage processing #####
|
||||
@@ -1786,11 +1857,18 @@ if (!$T)
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if (!$Q) {print STDERR "records deleted from vicidial_api_urls_archive: $affected_rowsA|$stmtA|\n";}
|
||||
|
||||
if ($NO_OPTIMIZE_TABLES < 1)
|
||||
{
|
||||
$stmtA = "OPTIMIZE TABLE vicidial_api_urls_archive;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
if (!$Q) {print STDERR "vicidial_api_urls_archive table optimized, cold-storage process is complete for this table!\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$Q) {print STDERR "vicidial_api_urls_archive table skip optimize\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
##### END vicidial_api_urls_archive cold-storage processing #####
|
||||
@@ -1941,11 +2019,18 @@ if (!$T)
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if (!$Q) {print STDERR "records deleted from vicidial_agent_visibility_log_archive: $affected_rowsA|$stmtA|\n";}
|
||||
|
||||
if ($NO_OPTIMIZE_TABLES < 1)
|
||||
{
|
||||
$stmtA = "OPTIMIZE TABLE vicidial_agent_visibility_log_archive;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
if (!$Q) {print STDERR "vicidial_agent_visibility_log_archive table optimized, cold-storage process is complete for this table!\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$Q) {print STDERR "vicidial_agent_visibility_log_archive table skip optimize\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
##### END vicidial_agent_visibility_log_archive cold-storage processing #####
|
||||
@@ -2100,11 +2185,18 @@ if (!$T)
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if (!$Q) {print STDERR "records deleted from vicidial_log_extended_sip_archive: $affected_rowsA|$stmtA|\n";}
|
||||
|
||||
if ($NO_OPTIMIZE_TABLES < 1)
|
||||
{
|
||||
$stmtA = "OPTIMIZE TABLE vicidial_log_extended_sip_archive;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
if (!$Q) {print STDERR "vicidial_log_extended_sip_archive table optimized, cold-storage process is complete for this table!\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$Q) {print STDERR "vicidial_log_extended_sip_archive table skip optimize\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
##### END vicidial_log_extended_sip_archive cold-storage processing #####
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
LOG ARCHIVING AND COLD STORAGE DOC Started: 2024-07-04 Updated: 2024-07-05
|
||||
LOG ARCHIVING AND COLD STORAGE DOC Started: 2024-07-04 Updated: 2024-07-11
|
||||
|
||||
|
||||
This document covers the options for archiving of specific log tables and the new "Cold Storage" features
|
||||
@@ -126,6 +126,7 @@ allowed run time options:
|
||||
[--quiet] = quiet
|
||||
[--calc-test] = date calculation test only
|
||||
[--query-count-test] = run archive counts test only
|
||||
[--no-optimize-tables] = do not optimize the archive tables after deletion of rows
|
||||
[--test] = test
|
||||
[--debug] = debug output for some options
|
||||
[--debugX] = extra debug output for some options
|
||||
|
||||
Reference in New Issue
Block a user