summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-12-14 18:09:23 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2020-12-14 18:09:23 +0200
commit588bd85d360a317966a23a39fc12ea9783f891cf (patch)
tree3162b4be3bd8ab51023700307a7d7338b1266728 /sql/sql_select.cc
parentb96cb3c21b011c90523a9392078cc46a2e6bd22e (diff)
parent9ecd76652664ec92836ce8c4a7a98ff5dbe7bf46 (diff)
downloadmariadb-git-bb-10.6-MDEV-21452.tar.gz
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index bf3d4fd9bb1..caaf6d2f3e3 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -7926,7 +7926,8 @@ best_access_path(JOIN *join,
access is to use the same index IDX, with the same or more key parts.
(note: it is not clear how this rule is/should be extended to
index_merge quick selects). Also if we have a hash join we prefer that
- over a table scan
+ over a table scan. This heuristic doesn't apply if the quick select
+ uses the group-by min-max optimization.
(3) See above note about InnoDB.
(4) NOT ("FORCE INDEX(...)" is used for table and there is 'ref' access
path, but there is no quick select)
@@ -7944,7 +7945,9 @@ best_access_path(JOIN *join,
Json_writer_object trace_access_scan(thd);
if ((records >= s->found_records || best > s->read_time) && // (1)
!(best_key && best_key->key == MAX_KEY) && // (2)
- !(s->quick && best_key && s->quick->index == best_key->key && // (2)
+ !(s->quick &&
+ s->quick->get_type() != QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX && // (2)
+ best_key && s->quick->index == best_key->key && // (2)
best_max_key_part >= s->table->opt_range[best_key->key].key_parts) &&// (2)
!((s->table->file->ha_table_flags() & HA_TABLE_SCAN_ON_INDEX) && // (3)
! s->table->covering_keys.is_clear_all() && best_key && !s->quick) &&// (3)