Get row estimate from NibbleIterator. Use user's index over MySQL's index when --where is given.

This commit is contained in:
Daniel Nichter
2011-10-13 09:23:53 -06:00
parent 28fa7d62c2
commit 964bb094a0
4 changed files with 193 additions and 122 deletions

View File

@@ -214,6 +214,7 @@ sub new {
};
}
$self->{row_est} = $row_est;
$self->{nibbleno} = 0;
$self->{have_rows} = 0;
$self->{rowno} = 0;
@@ -373,6 +374,11 @@ sub more_boundaries {
return !$self->{no_more_boundaries};
}
sub row_estimate {
my ($self) = @_;
return $self->{row_est};
}
sub _find_best_index {
my (%args) = @_;
my @required_args = qw(Cxn tbl TableParser);
@@ -381,12 +387,15 @@ sub _find_best_index {
my $indexes = $tbl_struct->{keys};
my $want_index = $args{chunk_index};
MKDEBUG && _d('Wanted index:', $want_index);
if ( $want_index && !exists $indexes->{$want_index} ) {
MKDEBUG && _d('Wanted index does not exist; will auto-select best index');
$want_index = undef;
if ( $want_index ) {
MKDEBUG && _d('User wants to use index', $want_index);
if ( !exists $indexes->{$want_index} ) {
MKDEBUG && _d('Cannot use user index because it does not exist');
$want_index = undef;
}
}
elsif ( $args{mysql_index} ) {
if ( !$want_index && $args{mysql_index} ) {
MKDEBUG && _d('MySQL wants to use index', $args{mysql_index});
$want_index = $args{mysql_index};
}