mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-12 14:18:32 +00:00
Remove --chunk-index-columns and extend --chunk-index instead to take INDEX:N value. Add n_index_values to TableNibbler.
This commit is contained in:
@@ -5991,6 +5991,25 @@ 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
|
||||||
|
my ($chunk_index, $n_chunk_index_cols)
|
||||||
|
= split(':', $o->get('chunk-index') || '');
|
||||||
|
if ( defined $chunk_index && !$chunk_index ) {
|
||||||
|
$o->save_error('--chunk-index cannot be an empty string');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$chunk_index = lc $chunk_index;
|
||||||
|
}
|
||||||
|
if ( defined $n_chunk_index_cols
|
||||||
|
&& (!$n_chunk_index_cols
|
||||||
|
|| $n_chunk_index_cols =~ m/[^\d]/
|
||||||
|
|| $n_chunk_index_cols < 1) ) {
|
||||||
|
$o->save_error('Invalid number of --chunk-index columns: '
|
||||||
|
. $n_chunk_index_cols);
|
||||||
|
}
|
||||||
|
|
||||||
if ( !$o->get('help') ) {
|
if ( !$o->get('help') ) {
|
||||||
if ( @ARGV > 1 ) {
|
if ( @ARGV > 1 ) {
|
||||||
$o->save_error("More than one host specified; only one allowed");
|
$o->save_error("More than one host specified; only one allowed");
|
||||||
@@ -6910,22 +6929,23 @@ sub main {
|
|||||||
my $nibble_iter;
|
my $nibble_iter;
|
||||||
eval {
|
eval {
|
||||||
$nibble_iter = new OobNibbleIterator(
|
$nibble_iter = new OobNibbleIterator(
|
||||||
Cxn => $master_cxn,
|
Cxn => $master_cxn,
|
||||||
tbl => $tbl,
|
tbl => $tbl,
|
||||||
chunk_size => $tbl->{chunk_size},
|
chunk_size => $tbl->{chunk_size},
|
||||||
chunk_index => $o->get('chunk-index'),
|
chunk_index => $chunk_index,
|
||||||
dml => $checksum_dml,
|
n_chunk_index_cols => $n_chunk_index_cols,
|
||||||
select => $checksum_cols,
|
dml => $checksum_dml,
|
||||||
past_dml => $checksum_dml,
|
select => $checksum_cols,
|
||||||
past_select => $past_cols,
|
past_dml => $checksum_dml,
|
||||||
callbacks => $callbacks,
|
past_select => $past_cols,
|
||||||
resume => $last_chunk,
|
callbacks => $callbacks,
|
||||||
OptionParser => $o,
|
resume => $last_chunk,
|
||||||
Quoter => $q,
|
OptionParser => $o,
|
||||||
TableNibbler => $tn,
|
Quoter => $q,
|
||||||
TableParser => $tp,
|
TableNibbler => $tn,
|
||||||
RowChecksum => $rc,
|
TableParser => $tp,
|
||||||
comments => {
|
RowChecksum => $rc,
|
||||||
|
comments => {
|
||||||
bite => "checksum table",
|
bite => "checksum table",
|
||||||
nibble => "checksum chunk",
|
nibble => "checksum chunk",
|
||||||
},
|
},
|
||||||
@@ -8037,12 +8057,6 @@ 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.
|
||||||
|
|
||||||
=item --chunk-index-columns
|
|
||||||
|
|
||||||
type: int
|
|
||||||
|
|
||||||
Number of left-most L<"--chunk-index"> columns to use.
|
|
||||||
|
|
||||||
=item --chunk-size
|
=item --chunk-size
|
||||||
|
|
||||||
type: size; default: 1000
|
type: size; default: 1000
|
||||||
|
@@ -124,10 +124,11 @@ sub new {
|
|||||||
# Figure out how to nibble the table with the index.
|
# Figure out how to nibble the table with the index.
|
||||||
my $asc = $args{TableNibbler}->generate_asc_stmt(
|
my $asc = $args{TableNibbler}->generate_asc_stmt(
|
||||||
%args,
|
%args,
|
||||||
tbl_struct => $tbl->{tbl_struct},
|
tbl_struct => $tbl->{tbl_struct},
|
||||||
index => $index,
|
index => $index,
|
||||||
cols => \@cols,
|
n_index_cols => $args{n_chunk_index_cols},
|
||||||
asc_only => 1,
|
cols => \@cols,
|
||||||
|
asc_only => 1,
|
||||||
);
|
);
|
||||||
PTDEBUG && _d('Ascend params:', Dumper($asc));
|
PTDEBUG && _d('Ascend params:', Dumper($asc));
|
||||||
|
|
||||||
|
@@ -41,6 +41,7 @@ sub new {
|
|||||||
# * tbl_struct Hashref returned from TableParser::parse().
|
# * tbl_struct Hashref returned from TableParser::parse().
|
||||||
# * cols Arrayref of columns to SELECT from the table
|
# * cols Arrayref of columns to SELECT from the table
|
||||||
# * index Which index to ascend; optional.
|
# * index Which index to ascend; optional.
|
||||||
|
# * n_index_cols The number of left-most index columns to use.
|
||||||
# * asc_only Whether to ascend strictly, that is, the WHERE clause for
|
# * asc_only Whether to ascend strictly, that is, the WHERE clause for
|
||||||
# the asc_stmt will fetch the next row > the given arguments.
|
# the asc_stmt will fetch the next row > the given arguments.
|
||||||
# The option is to fetch the row >=, which could loop
|
# The option is to fetch the row >=, which could loop
|
||||||
@@ -77,8 +78,12 @@ sub generate_asc_stmt {
|
|||||||
# These are the columns we'll ascend.
|
# These are the columns we'll ascend.
|
||||||
my @asc_cols = @{$tbl_struct->{keys}->{$index}->{cols}};
|
my @asc_cols = @{$tbl_struct->{keys}->{$index}->{cols}};
|
||||||
if ( $args{asc_first} ) {
|
if ( $args{asc_first} ) {
|
||||||
@asc_cols = $asc_cols[0];
|
|
||||||
PTDEBUG && _d('Ascending only first column');
|
PTDEBUG && _d('Ascending only first column');
|
||||||
|
@asc_cols = $asc_cols[0];
|
||||||
|
}
|
||||||
|
elsif ( my $n = $args{n_index_cols} ) {
|
||||||
|
PTDEBUG && _d('Ascending only first', $n, 'columns');
|
||||||
|
@asc_cols = @asc_cols[0..($n-1)];
|
||||||
}
|
}
|
||||||
PTDEBUG && _d('Will ascend columns', join(', ', @asc_cols));
|
PTDEBUG && _d('Will ascend columns', join(', ', @asc_cols));
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@ BEGIN {
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use Test::More tests => 24;
|
use Test::More tests => 25;
|
||||||
|
|
||||||
use TableParser;
|
use TableParser;
|
||||||
use TableNibbler;
|
use TableNibbler;
|
||||||
@@ -297,6 +297,34 @@ is_deeply(
|
|||||||
'Alternate index with asc_first on sakila.rental',
|
'Alternate index with asc_first on sakila.rental',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
is_deeply(
|
||||||
|
$n->generate_asc_stmt(
|
||||||
|
tbl_struct => $t,
|
||||||
|
cols => $t->{cols},
|
||||||
|
index => 'rental_date',
|
||||||
|
n_index_cols => 2,
|
||||||
|
),
|
||||||
|
{
|
||||||
|
cols => [qw(rental_id rental_date inventory_id customer_id
|
||||||
|
return_date staff_id last_update)],
|
||||||
|
index => 'rental_date',
|
||||||
|
where => '((`rental_date` > ?) OR (`rental_date` = ? AND `inventory_id` >= ?))',
|
||||||
|
slice => [qw(1 1 2)],
|
||||||
|
scols => [qw(rental_date rental_date inventory_id)],
|
||||||
|
boundaries => {
|
||||||
|
'<' =>
|
||||||
|
'((`rental_date` < ?) OR (`rental_date` = ? AND `inventory_id` < ?))',
|
||||||
|
'<=' =>
|
||||||
|
'((`rental_date` < ?) OR (`rental_date` = ? AND `inventory_id` <= ?))',
|
||||||
|
'>' =>
|
||||||
|
'((`rental_date` > ?) OR (`rental_date` = ? AND `inventory_id` > ?))',
|
||||||
|
'>=' =>
|
||||||
|
'((`rental_date` > ?) OR (`rental_date` = ? AND `inventory_id` >= ?))'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'Use only N left-most columns of the index',
|
||||||
|
);
|
||||||
|
|
||||||
is_deeply(
|
is_deeply(
|
||||||
$n->generate_asc_stmt(
|
$n->generate_asc_stmt(
|
||||||
tbl_struct => $t,
|
tbl_struct => $t,
|
||||||
|
Reference in New Issue
Block a user