Add --chunk-index-columns to pt-osc.

This commit is contained in:
Daniel Nichter
2012-06-11 08:15:48 -04:00
parent 823cedd9ba
commit d2486ebdf6
2 changed files with 16 additions and 21 deletions

View File

@@ -1893,6 +1893,7 @@ sub generate_asc_stmt {
@asc_cols = $asc_cols[0]; @asc_cols = $asc_cols[0];
} }
elsif ( my $n = $args{n_index_cols} ) { elsif ( my $n = $args{n_index_cols} ) {
$n = scalar @asc_cols if $n > @asc_cols;
PTDEBUG && _d('Ascending only first', $n, 'columns'); PTDEBUG && _d('Ascending only first', $n, 'columns');
@asc_cols = @asc_cols[0..($n-1)]; @asc_cols = @asc_cols[0..($n-1)];
} }
@@ -5209,14 +5210,8 @@ sub main {
} }
} }
# Parse --chunk-index INDEX:N where N is the number of
# left-most columns of INDEX to use.
# https://bugs.launchpad.net/percona-toolkit/+bug/1010232 # https://bugs.launchpad.net/percona-toolkit/+bug/1010232
my ($chunk_index, $n_chunk_index_cols) my $n_chunk_index_cols = $o->get('chunk-index-columns');
= split(':', $o->get('chunk-index') || '');
if ( defined $chunk_index && $chunk_index eq '' ) {
$o->save_error('--chunk-index cannot be an empty string');
}
if ( defined $n_chunk_index_cols if ( defined $n_chunk_index_cols
&& (!$n_chunk_index_cols && (!$n_chunk_index_cols
|| $n_chunk_index_cols =~ m/\D/ || $n_chunk_index_cols =~ m/\D/
@@ -6108,8 +6103,8 @@ sub main {
Cxn => $cxn, Cxn => $cxn,
tbl => $orig_tbl, tbl => $orig_tbl,
chunk_size => $orig_tbl->{chunk_size}, chunk_size => $orig_tbl->{chunk_size},
chunk_index => $chunk_index, chunk_index => $o->get('chunk-index'),
n_chunk_index_cols => $n_chunk_index_cols, n_chunk_index_cols => $o->get('chunk-index-columns'),
dml => $dml, dml => $dml,
select => $select, select => $select,
callbacks => $callbacks, callbacks => $callbacks,
@@ -7453,16 +7448,18 @@ behavior of choosing an index. The tool adds the index to the SQL statements in
a C<FORCE INDEX> clause. Be careful when using this option; a poor choice of a C<FORCE INDEX> clause. Be careful when using this option; a poor choice of
index could cause bad performance. index could cause bad performance.
This option supports a special syntax to select a prefix of the index instead of =item --chunk-index-columns
the entire index. The syntax is NAME:N, where NAME is the name of the index, and
N is the number of columns you wish to use. This works only for compound type: int
indexes, and is useful in cases where a bug in the MySQL query optimizer
(planner) causes it to scan a large range of rows instead of using the index to Use only this many left-most columns of a L<"--chunk-index">. This works
locate starting and ending points precisely. This problem sometimes occurs on only for compound indexes, and is useful in cases where a bug in the MySQL
indexes with many columns, such as 4 or more. If this happens, the tool might query optimizer (planner) causes it to scan a large range of rows instead
print a warning related to the L<"--[no]check-plan"> option. Instructing of using the index to locate starting and ending points precisely. This
the tool to use only the first N columns from the index is a workaround for problem sometimes occurs on indexes with many columns, such as 4 or more.
the bug in some cases. If this happens, the tool might print a warning related to the
L<"--[no]check-plan"> option. Instructing the tool to use only the first
N columns of the index is a workaround for the bug in some cases.
=item --chunk-size =item --chunk-size

View File

@@ -6171,8 +6171,6 @@ sub main {
} }
} }
# Parse --chunk-index INDEX:N where N is the number of
# left-most columns of INDEX to use.
# https://bugs.launchpad.net/percona-toolkit/+bug/1010232 # https://bugs.launchpad.net/percona-toolkit/+bug/1010232
my $n_chunk_index_cols = $o->get('chunk-index-columns'); my $n_chunk_index_cols = $o->get('chunk-index-columns');
if ( defined $n_chunk_index_cols if ( defined $n_chunk_index_cols