diff options
author | Evgeny Potemkin <epotemkin@mysql.com> | 2010-02-26 14:19:44 +0300 |
---|---|---|
committer | Evgeny Potemkin <epotemkin@mysql.com> | 2010-02-26 14:19:44 +0300 |
commit | 6025d0ba6b190a691aff4b35ca0a31d87444fa19 (patch) | |
tree | a17ba0412ba1a37a5ad9c71c5fc0f9fc7b4170fc /sql | |
parent | 936ed6ca86633a91976fd6fcd931683ec007f440 (diff) | |
parent | 2d4db52edac1488c9481b303095229b424288e64 (diff) | |
download | mariadb-git-6025d0ba6b190a691aff4b35ca0a31d87444fa19.tar.gz |
Auto-merged fox for the bug#50843.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_select.cc | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b9f59fac4d6..a180704c6ca 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13306,12 +13306,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, */ if (select_limit >= table_records) { - /* - filesort() and join cache are usually faster than reading in - index order and not using join cache - */ - if (tab->type == JT_ALL && tab->join->tables > tab->join->const_tables + 1) - DBUG_RETURN(0); keys= *table->file->keys_to_use_for_scanning(); keys.merge(table->covering_keys); @@ -13461,6 +13455,19 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, } } } + + /* + filesort() and join cache are usually faster than reading in + index order and not using join cache, except in case that chosen + index is clustered primary key. + */ + if ((select_limit >= table_records) && + (tab->type == JT_ALL && + tab->join->tables > tab->join->const_tables + 1) && + ((unsigned) best_key != table->s->primary_key || + !table->file->primary_key_is_clustered())) + DBUG_RETURN(0); + if (best_key >= 0) { bool quick_created= FALSE; |