Merge branch 'pt-tcs-where-option-using-non-optimal-index-lp1576036' of github.com:percona/percona-toolkit into pt-tcs-where-option-using-non-optimal-index-lp1576036

This commit is contained in:
frank-cizmich
2016-05-11 18:10:05 -03:00
2 changed files with 4 additions and 2 deletions

View File

@@ -6560,7 +6560,7 @@ sub _find_best_index {
}
}
if (!$best_index && !$want_index) {
if (!$best_index) {
PTDEBUG && _d('Auto-selecting best index');
foreach my $index ( $tp->sort_indexes($tbl_struct) ) {
if ( $index eq 'PRIMARY' || $indexes->{$index}->{is_unique} ) {

View File

@@ -540,7 +540,8 @@ sub _find_best_index {
}
}
# still no best index? select amongst all candidates.
# still no best index?
# prefer unique index. otherwise put in candidates array.
if (!$best_index) {
PTDEBUG && _d('Auto-selecting best index');
foreach my $index ( $tp->sort_indexes($tbl_struct) ) {
@@ -554,6 +555,7 @@ sub _find_best_index {
}
}
# choose the one with best cardinality
if ( !$best_index && @possible_indexes ) {
PTDEBUG && _d('No PRIMARY or unique indexes;',
'will use index with highest cardinality');