mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-28 00:21:56 +00:00
Add --chunk-index-columns to pt-table-checksum.
This commit is contained in:
@@ -2294,6 +2294,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)];
|
||||||
}
|
}
|
||||||
@@ -6173,11 +6174,7 @@ sub main {
|
|||||||
# Parse --chunk-index INDEX:N where N is the number of
|
# Parse --chunk-index INDEX:N where N is the number of
|
||||||
# left-most columns of INDEX to use.
|
# 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/
|
||||||
@@ -7116,8 +7113,8 @@ sub main {
|
|||||||
Cxn => $master_cxn,
|
Cxn => $master_cxn,
|
||||||
tbl => $tbl,
|
tbl => $tbl,
|
||||||
chunk_size => $tbl->{chunk_size},
|
chunk_size => $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 => $checksum_dml,
|
dml => $checksum_dml,
|
||||||
select => $checksum_cols,
|
select => $checksum_cols,
|
||||||
past_dml => $checksum_dml,
|
past_dml => $checksum_dml,
|
||||||
@@ -8302,16 +8299,18 @@ when using this option; a poor choice of index could cause bad performance.
|
|||||||
This is probably best to use when you are checksumming only a single table, not
|
This is probably best to use when you are checksumming only a single table, not
|
||||||
an entire server.
|
an entire server.
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@ if ( !$dbh ) {
|
|||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
plan tests => 15;
|
plan tests => 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
|
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
|
||||||
@@ -193,17 +193,30 @@ ok(
|
|||||||
pt_table_checksum::main(
|
pt_table_checksum::main(
|
||||||
$master_dsn, '--max-load', '',
|
$master_dsn, '--max-load', '',
|
||||||
qw(--lock-wait-timeout 3 --chunk-size 5000 -t sakila.rental),
|
qw(--lock-wait-timeout 3 --chunk-size 5000 -t sakila.rental),
|
||||||
qw(--chunk-index rental_date:2 --explain --explain));
|
qw(--chunk-index rental_date --chunk-index-columns 2),
|
||||||
|
qw(--explain --explain));
|
||||||
},
|
},
|
||||||
"t/pt-table-checksum/samples/n-chunk-index-cols.txt",
|
"t/pt-table-checksum/samples/n-chunk-index-cols.txt",
|
||||||
),
|
),
|
||||||
"--chunk-index index:n"
|
"--chunk-index-columns"
|
||||||
);
|
);
|
||||||
|
|
||||||
pt_table_checksum::main(
|
$output = output(
|
||||||
$master_dsn, '--max-load', '',
|
sub {
|
||||||
qw(--lock-wait-timeout 3 --chunk-size 5000 -t sakila.rental),
|
$exit_status = pt_table_checksum::main(
|
||||||
qw(--chunk-index rental_date:5 --explain --explain));
|
$master_dsn, '--max-load', '',
|
||||||
|
qw(--lock-wait-timeout 3 --chunk-size 5000 -t sakila.rental),
|
||||||
|
qw(--chunk-index rental_date --chunk-index-columns 5),
|
||||||
|
qw(--explain --explain));
|
||||||
|
},
|
||||||
|
stderr => 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
is(
|
||||||
|
$exit_status,
|
||||||
|
0,
|
||||||
|
"--chunk-index-columns > number of index columns"
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
|
Reference in New Issue
Block a user