summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMartin Hansson <martin.hansson@sun.com>2009-08-10 16:08:51 +0200
committerMartin Hansson <martin.hansson@sun.com>2009-08-10 16:08:51 +0200
commit527e5fd3a246cc21bdaa3e15952b61bd3e13ebcd (patch)
tree730562ba730c441683468c05ad9f93eef01f6cde /sql
parent466847a0b840dc7db8ecd76fed92eadab0c01132 (diff)
parent4c3917b6f8b110046ad7e506abe78086ef38d1cc (diff)
downloadmariadb-git-527e5fd3a246cc21bdaa3e15952b61bd3e13ebcd.tar.gz
Merge
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_select.cc25
-rw-r--r--sql/table.h8
2 files changed, 20 insertions, 13 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index c900588212c..7f6c5e834a3 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -6151,7 +6151,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
}
}
- if (tmp || !cond)
+ if (tmp || !cond || tab->type == JT_REF)
{
DBUG_EXECUTE("where",print_where(tmp,tab->table->alias, QT_ORDINARY););
SQL_SELECT *sel= tab->select= ((SQL_SELECT*)
@@ -6165,7 +6165,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
The guard will turn the predicate on only after
the first match for outer tables is encountered.
*/
- if (cond)
+ if (cond && tmp)
{
/*
Because of QUICK_GROUP_MIN_MAX_SELECT there may be a select without
@@ -12946,6 +12946,8 @@ find_field_in_item_list (Field *field, void *data)
The index must cover all fields in <order>, or it will not be considered.
+ @param no_changes No changes will be made to the query plan.
+
@todo
- sergeyp: Results of all index merge selects actually are ordered
by clustered PK values.
@@ -13280,6 +13282,15 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
}
if (!no_changes)
{
+ /*
+ If ref_key used index tree reading only ('Using index' in EXPLAIN),
+ and best_key doesn't, then revert the decision.
+ */
+ if (!table->covering_keys.is_set(best_key) && table->key_read)
+ {
+ table->key_read= 0;
+ table->file->extra(HA_EXTRA_NO_KEYREAD);
+ }
if (!quick_created)
{
tab->index= best_key;
@@ -13296,16 +13307,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
table->key_read=1;
table->file->extra(HA_EXTRA_KEYREAD);
}
- else if (table->key_read)
- {
- /*
- Clear the covering key read flags that might have been
- previously set for some key other than the current best_key.
- */
- table->key_read= 0;
- table->file->extra(HA_EXTRA_NO_KEYREAD);
- }
-
table->file->ha_index_or_rnd_end();
if (join->select_options & SELECT_DESCRIBE)
{
diff --git a/sql/table.h b/sql/table.h
index 98ede52cd99..653d04b149e 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -755,7 +755,13 @@ struct st_table {
*/
my_bool force_index;
my_bool distinct,const_table,no_rows;
- my_bool key_read, no_keyread;
+
+ /**
+ If set, the optimizer has found that row retrieval should access index
+ tree only.
+ */
+ my_bool key_read;
+ my_bool no_keyread;
/*
Placeholder for an open table which prevents other connections
from taking name-locks on this table. Typically used with