summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorSergey Glukhov <Sergey.Glukhov@sun.com>2010-02-26 16:19:05 +0400
committerSergey Glukhov <Sergey.Glukhov@sun.com>2010-02-26 16:19:05 +0400
commit03561d35e30807e841c8544a6f5c07d708c6acbd (patch)
tree4ca0ab39dc0cce908511ad93faf32e7b294f86d8 /sql/sql_select.cc
parent9245ed4a12ce25214d60f93cbf20882cb2b78741 (diff)
parent6025d0ba6b190a691aff4b35ca0a31d87444fa19 (diff)
downloadmariadb-git-03561d35e30807e841c8544a6f5c07d708c6acbd.tar.gz
automerge
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 1d88343ad6d..773aa7da139 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -13307,12 +13307,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);
@@ -13462,6 +13456,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;