Commit fa96f28e authored by Andreas Kusalananda Kähäri's avatar Andreas Kusalananda Kähäri
Browse files

By default, optimize the tables on the source database server. This is

to flush index data to file before copying.

Add new flag:

  --noopt           (Optional)
                    Skip the optimization step.  The database tables are
                    optimized (as with "OPTIMIZE TABLE") to flush the
                    index data onto disk.  This may be a time consuming
                    operation for very large tables.  The --noopt flag
                    disables the optimization.
parent 25cb044c
#!/usr/local/ensembl/bin/perl -w
#!/usr/bin/env perl
use strict;
use warnings;
......@@ -29,9 +29,9 @@ EOT
sub long_usage {
my $indent = ' ' x length($0);
print <<EOT;
print <<USAGE_END;
Usage:
$0 --pass=XXX [--noflush] [--nocheck] [--force] \\
$0 --pass=XXX [--noflush] [--nocheck] [--noopt] [--force] \\
$indent [--subset=XXX] [--help] input_file
Description:
......@@ -63,6 +63,13 @@ Command line switches:
time to wait for the check to run. Use only after
due consideration.
--noopt (Optional)
Skip the optimization step. The database tables are
optimized (as with "OPTIMIZE TABLE") to flush the
index data onto disk. This may be a time consuming
operation for very large tables. The --noopt flag
disables the optimization.
--force (Optional)
Ordinarily, the script refuses to overwrite an
already existing staging directory. This switch
......@@ -116,28 +123,25 @@ Script restrictions:
stage.
EOT
USAGE_END
} ## end sub long_usage
my (
$opt_password, $opt_flush, $opt_check,
$opt_force, $opt_subset, $opt_help
);
$opt_flush = 1; # Flush by default.
$opt_check = 1; # Check tables by default.
$opt_force = 0; # Do not reuse existing staging directory by default.
if (
!GetOptions(
'pass=s' => \$opt_password,
'flush!' => \$opt_flush,
'check!' => \$opt_check,
'force!' => \$opt_force,
'subset=s' => \$opt_subset,
'help' => \$opt_help
)
|| ( !defined($opt_password) && !defined($opt_help) ) )
my ( $opt_password, $opt_flush, $opt_check, $opt_optimize,
$opt_force, $opt_subset, $opt_help );
$opt_flush = 1; # Flush by default.
$opt_check = 1; # Check tables by default.
$opt_optimize = 1; # Optimize the tables by default.
$opt_force = 0; # Do not reuse existing staging directory by default.
if ( !GetOptions( 'pass=s' => \$opt_password,
'flush!' => \$opt_flush,
'check!' => \$opt_check,
'opt!' => \$opt_optimize,
'force!' => \$opt_force,
'subset=s' => \$opt_subset,
'help' => \$opt_help )
|| ( !defined($opt_password) && !defined($opt_help) ) )
{
short_usage();
exit 1;
......@@ -486,6 +490,20 @@ foreach my $spec (@todo) {
sprintf( "FLUSH TABLES %s", join( ', ', @tables ) ) );
}
##------------------------------------------------------------------##
## OPTIMIZE ##
##------------------------------------------------------------------##
if ($opt_optimize) {
print( '-' x 35, ' OPTIMIZE ', '-' x 35, "\n" );
foreach my $table (@tables) {
printf( "Optimizing table '%s'...", $table );
$source_dbh->do( sprintf( "OPTIMIZE TABLE %s", $table ) );
print("\tok\n");
}
}
##------------------------------------------------------------------##
## COPY ##
##------------------------------------------------------------------##
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment